The Wayback Machine - https://web.archive.org/web/20201026224628/https://github.com/Intervention/image/pull/1008
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support making ICO and CUR files from strings (Imagemagick) #1008

Open
wants to merge 1 commit into
base: master
from

Conversation

@ziadoz
Copy link

@ziadoz ziadoz commented Mar 4, 2020

If you try to make an image from an ICO or CUR image string using the Imagemagick driver an Unable to read image from binary data exception is thrown. If you try from a path however it works, because Imagick can determine the image type using the file extension.

I've fixed loading from a string here by checking the first four bytes of the binary to see if the string is an ICO or CUR file, and then set the appropriate format on the Imagick object. I've added test coverage for this scenario, and also for loading ICO and CUR files using paths and Imagick objects too.

One odd thing I noticed is that finfo_open() returns image/vnd.microsoft.icon on my machine, but the Travis CI builds return image/x-icon. I don't know how much this matters though, as this can be dealt with in userland (there are numerous mime types for ICO, so easy enough to check).

I previously opened a bug for this, but I've closed that and opened this fix instead (there's some examples of the issue there): #1007

Thanks!

@ziadoz ziadoz changed the title Support making ICO and CUR files from strings Support making ICO and CUR files from strings (Imagemagick) Mar 4, 2020
@ziadoz ziadoz force-pushed the ziadoz:load-ico-from-string branch 2 times, most recently from 42adc3b to 19ba5c4 Mar 4, 2020
Add comment.

Ensure MIME is always IANA standard.

Adjust comment.

Use image/x-icon MIME.

Fix bug.

Add data URL and base64 tests.
@ziadoz ziadoz force-pushed the ziadoz:load-ico-from-string branch from 19ba5c4 to 0191746 Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant
You can’t perform that action at this time.