Closed zmike808GS closed 9 years ago
Thanks for the pull request, but I'm afraid this change may break PNG, WebP, and some transparent GIF. Indeed, sometimes, the output file larger than original file is a normal behavior, it is common for GD or Imagemagick. Imagecraft even has an algorithm that can compress the output GIF, so don't worry, the output file won't be too larger than the original.
Anyway, I have saved your work as a new branch in the repository, and I will examine it in the future. If you have any question, feel free to leave a message.
Here's the gif I used:
Here's the results I got from calling resize, as you can see the file size does increase:
Oh, I got you. This is because imagecraft has two modes for animated GIF, the "fallback" mode and "optimize" mode, and it is determined by the frames, size, render method of the source GIF and destination GIF. In fallback mode, Images are processed much faster, and the final GIF tend to be smaller, but in low quality, and PNG watermark may not work properly. The files (923KB, 828KB, 720KB) actually use the "fallback" resize, and the rest of the files use "optimize" resize. You can manually replace the $quality
to true
or false
in code, and see the result.
If you use Imagecraft merely to resize images (without PNG watermarks), you can set the $quality
always to false
, you will see a great performance boost, relevant issue.
When I would resize an animated GIF, there would be certain resized versions that had a larger file size than the original GIF. For example when resizing a 400x227 980KB animated GIF to the dimensions 300x170, would result in a file size of 1.52MB (for the 300x170 GIF). Changing imagecreatetruecolor to imagecreate in getEmptyGdResource seems to fix this issue.