Php request favicon ico

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

A high quality PHP package for reading and converting any .ico icon file, particularly website favicons

License

lordelph/icofileloader

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Читайте также:  Css inline style margin

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

This package provides a means to load and convert .ico files in a PHP application. It has no dependencies apart from gd for rendering.

The package has unit tests which verify support for 1bit, 4bit, 8bit, 24bit and 32bit .ico files, and the newer form of .ico files which can included embedded PNG files.

For recent php versions (8.*) IcoFileLoader is available via Composer:

composer require lordelph/icofileloader

Earlier versions of php from 5.6 onwards can use version 2 of IcoFileLoader

composer require lordelph/icofileloader:2.*

If you need to use php5.4 or php5.5, you must install the v1.* branch

composer require lordelph/icofileloader:1.*

The IcoFileService class provides a one-shot method extractIcon . This should suit most use-cases where you simply want to get one image out of a .ico file.

It returns an image resource, which you can further manipulate with GD functions, e.g. save it to a file with imagepng

For example, here’s how you extract a 32×32 transparent image from an ico file:

$loader = new Elphin\IcoFileLoader\IcoFileService; $im = $loader->extractIcon('/path/to/icon.ico', 32, 32); //$im is a GD image resource, so we could, for example, save this as a PNG imagepng($im, '/path/to/output.png');

Render with background color

Instead of retaining the alpha channel from the icon, you can render with a background color instead — pass the required color as a renderer option as follows:

$im = $loader->extractIcon('/path/to/icon.ico', 32, 32, ['background'=>'#FFFFFF']);

The extractIcon method will try find an image in the icon which is the exact size you request at highest color depth it can find. If it can’t, it will resize the best quality image in the icon. So, you can request any size you require.

$im = $loader->extractIcon('/path/to/icon.ico', 100, 100);

As long you have the PHP fopen wrappers installed, you can pass a URL to extractIcon

$im = $loader->extractIcon('https://assets-cdn.github.com/favicon.ico', 16, 16);

Extract icon from binary data

If you already have an ico file held as a binary string, extractIcon will cope with that just fine too:

$data = file_get_contents('/path/to/icon.ico'); $im = $loader->extractIcon($data, 16, 16);

If you want to do more than just extract a single image from an icon, you can use lower level methods of IcoFileService to inspect an .ico file and perform multiple renderings.

The fromFile , fromString and from methods will parse an ico file and return an Icon instance representing an icon and the images it contains.

You can iterate the images in icon, examine them, and render them with renderImage

For example, here’s how you could extract all the images in an icon and save them as individual files.

$icon = $loader->fromFile('/path/to/icon.ico'); foreach ($icon as $idx => $image) < $im=$loader->renderImage($image); $filename=sprintf('img%d-%dx%d.png', $idx, $image->width, $image->height); imagepng($im, $filename); printf("rendered %s as %s\n", $image->getDescription(), $filename); >

The service is composed of a parser and a renderer, which can be injected into the service at runtime if you wanted to override them.

The current GdRenderer works by drawing individual pixels for BMP based icon images. This isn’t going to be terribly fast. PHP 7.2 will have support for BMP images, and I’ll add a renderer which takes advantage of that when it is released.

Thanks also to the PHP League’s skeleton project from which this project’s structure was derived.

The MIT License (MIT). Please see License File for more information.

Note: this was based on some classes originally written in 2005 by Diogo Resende. While these were originally provided on the PHPClasses site under a GPL license, Diogo kindly agreed to allow them to be licensed under an MIT license.

About

A high quality PHP package for reading and converting any .ico icon file, particularly website favicons

Источник

REQUEST_URI of a php document is «favicon.ico» or a stylesheet’s filename

Solution 2: The answer is: the link should trump the local file on most modern browsers, but it really depends on the implementation with non-mainstream browsers (although you probably don’t really care about other browsers than IE, Firefox, Safari and Chrome) Solution 3: Don’t forget that browsers aren’t the only thing that will request favicon’s — many crawlers and other applications do too.

REQUEST_URI of a php document is «favicon.ico» or a stylesheet’s filename

I log traffic coming in to my site. I get a user’s landing page by looking at the REQUEST_URI of the first page they come to. The site is all php so every page includes a file that has, among some other things:

$_SESSION['landing']=$_SERVER['REQUEST_URI']; 

I also log traffic going out. I’ve noticed two kinds of entries for $_SESSION[‘landing’] though that don’t quite make sense. I’ll see either: «favicon.ico» or «ie8.css»

Favicon is just a favicon:

ie8.css is a stylesheet that fixes a couple of things so they’ll look right in IE8. I include it like this:

Why would these show up as the $_SERVER[‘REQUEST_URI’] for a php document?

The are 3 reason i know that can cause such error .

  1. Error URL redirection . when trying to implement clean URL .
  2. `AddType x-httpd-php .css .ico .xyz
  3. Someone is messing with your server .

This for steering me in the right direction. I was using a rewrite rule to simulate a «county» directory e.g. :

/county/Sonoma?1, /county/Sonoma?2, etc. 

to distinguish counties from cities which look like /Santa Rosa. This is the rule:

RewriteCond % !/\.php/ [NC] RewriteRule ^county/(.+)$ /county.php?county=$1 [L,QSA] 

but my link to favicon.ico was relative, not absolute, i.e. favicon.icon instead of /favicon.ico . So apache was looking for /county/favicon.ico instead of /favicon.ico . And the RewriteRule was sending it to county.php.

The upshot was that $_SERVER[‘REQUEST_URI’] was /favicon.ico.

I prepended the slash and it worked. And for good measure I added another rule:

What is the use of serve favicon from Node.js server, User agents request frequently and indiscriminately for favicon. Use this middleware before your logger middleware to exclude these request from …

I want to set a favicon to be requested from a static file server instead of the main web server for performance optimization.

If I specify a but also have a /favicon.ico in my site root as a fallback, which will browsers prefer? Will browsers (and which?) still look for /favicon.ico , making the move to a static file server useless?

I did the test suggested above. I placed a /favicon.ico in the root of a domain, and a link, and fired up the page in:

  1. Opera 10
  2. Opera 9.64
  3. Firefox 3.5
  4. IE 6
  5. IE 7
  6. IE 8
  7. Safari 4

They all showed the icon loaded with (located on an external server). I checked access.log , and there were no requests to /favicon.ico !

I then commented out the , checked again in all browsers, and they showed the /favicon.ico icon and corresponding entries in access.log .

The answer is: the link should trump the local file on most modern browsers, but it really depends on the implementation with non-mainstream browsers (although you probably don’t really care about other browsers than IE, Firefox, Safari and Chrome)

It should also be pretty simple to test this yourself. Just put the favicon.ico file in the site folder and also add a link to a different-looking icon file on the static server and then see which one is loaded in different browsers.

Don’t forget that browsers aren’t the only thing that will request favicon’s — many crawlers and other applications do too.

Html — Favicon.ico not being requested, 1 Answer. The favicon.ico file gets cached by Chrome, so once it has been requested once, it will not be requested again until the cache expires. To …

Why is there an additional «favicon.ico» HTTP request?

Using the code from this answer: https://stackoverflow.com/a/9744961/514773

I’ve noticed that any time I enter: http://localhost:8080 into my browser the output result is:

http://localhost:8080/ http://localhost:8080/favicon.ico 

Subsequent requests print the same thing. This to me looks like I am getting two requests for price of one. Is this normal? (This is not my desired behavior.)

Browsers automatically request the favicon.ico file by default when you issue a request for a web page. The favicon.ico file is the small icon that appears in the URL bar of your browser.

How to suppress it though and where in case of jersey ? Have seen the solution as :

IIS8 Strange redirects to 302 after a 200, What request headers are sent back as part of the initial 200 response? Request GET /pico/favicon.ico HTTP/1.1 Host: 192.168.1.26 …

Can’t get proxy working in my react and node app

I’m making a react client app with a node.js express backend. Here is my project structure:

The client app is using a proxy, so in its package.json, it has the line:

This seems to cause the following error:

The browser requests a favicon.ico at the URL /favicon.ico . Normally, this would be a request to the react app, so the request would be made to localhost:3000/favicon.ico . But since we’re now using a proxy, the request gets sent to localhost:5000/favicon.ico , note the change in port number. This causes a proxy error, here’s what it says in the terminal:

Proxy error: Could not proxy request /favicon.ico from localhost:3000 to https://localhost:5000. [1] See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (EPROTO). 

In the browser, it says GET http://localhost:3000/favicon.ico 500 (Internal Server Error) .

I’m afraid that this problem will cause other problems with my app, so I want to get it out of the way. I’ve tried to do this in my server.js file:

Unfortunately, it doesn’t change the behaviour of the app. The exact same error happens, and the console.log doesn’t output anything, which makes me think that nothing even gets routed to the server. Now, here’s the most important question: Why is this? Why doesn’t the request go to the server?

ADDITIONAL INFO: Here’s the package.json file of the server, in the home folder. home/package.json:

< "name": "sentify-server", "version": "1.0.0", "scripts": < "client": "cd client && yarn start", "server": "nodemon server.js", "dev": "concurrently --kill-others-on-fail \"yarn server\" \"yarn client\"" >, "dependencies": < "express": "^4.16.3" >, "devDependencies": < "concurrently": "^3.5.0" >> 

After a lot of fiddling I found the problem. The proxy field in the package.json file is a https url. Changing it to http sorted the problem.

Had a similar problem and realized that I was inside the client folder rather than the parent server folder when I ran «npm start», just double check your folder.

it’s work if you use http instead of https

Azure Blob Container Getting 400 OutOfRangeInput One, Checking in to see if you have had a chance to see the previous response. Let us know if you need any further assistance in this matter.

Источник

Оцените статью