![]() With this, if you provide $imgFile as test-transparent1.png and $thumbnailFilename as, should come out being sized to fit 1024x724 and padded with transparent pixels so the original image is centered.įirst, in order to do a proportional scale, you'll need to set the bestfit parameter of scaleImage to true. I check the output thumbnail here because if you are outputting to a jpeg, regardless of the source, it's going to be stripped of transparency. $edge = shell_exec("convert $imgFile -resize 1024x724 -background $background -gravity center -extent 1024x724 -quality 90 $thumbnailFilename") $background = preg_match('/\.gif$|\.png$/', $thumbnailFilename) = 1 ? 'None' : 'white' (And, as mentioned, you will of course need to use png or gif output rather than jpg as jpeg can't handle transparency.) Normally I would do simple extension checking as it's good enough most of the time, but there are more detailed checks. extent flattens images, so to preserve the transparency the background will need to be None in those cases. What you'll need to do is determine if the image has, or might have, transparency and then set the background color to None. ![]() ![]() Right now if you try to use a transparent PNG (source and destination), instead of a jpeg, it'll flatten the image and make the background solid white, and you do not want this correct? If I am understanding what you want correctly, you are already part way there.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |