Page 1 of 1

Resize failing for transparent images on IM 6.5.4-7

Posted: 2014-02-05T07:42:12-07:00
by Carter J
ImageMagick Version - 6.5.4-7 2012-04-10 Q16

We have a watermark image and we need to resize it in accordance with the image that we are trying to apply the watermark, so we get the Width and height of the original image and then using convert resize the watermark accordingly and apply it on the original image so it fits the complete image.

To Resize
convert -resize 1875x2500 Watermark.PSD[0] Watermark_resized.PSD

Apply Watermark
composite -dissolve 40% -gravity center Watermark_resized.PSD[0] OriginalImage.jpg. OutputImage.jpg

In this process of resizing the watermark on the output, the watermark is showing only a fog kind layer on original image without maintaining the transparency and also loosing the watermark data.

If watermark(psd) is not resized, the watermark is getting applied without any issue
composite -dissolve 40% -gravity center Watermark.PSD[0] OriginalImage.jpg. OutputImage.jpg

To test the version incompatibilities, we resized the image on ImageMagick 6.8.7-5 Q16 version and then tried composite on 6.5.4-7 2012-04-10 Q16, the watermark applied without issues.

How can we resize and apply watermark on 6.5.4-7 2012-04-10, as we have to do this specifically on this version only.
Also I see in the forum from bugs section that 6.8.8-2 version of ImageMagick is also having problems with composite command. So help me how to overcome this

OriginalImage
https://www.dropbox.com/s/674ne9m5bi7tz ... lImage.jpg

watermark.psd
https://www.dropbox.com/s/ewthmhzmzb6rxjt/watermark.PSD

OutputImage.jpg
https://www.dropbox.com/s/2ejw44k2vp84o ... ge.jpg.jpg

Watermark_resized.psd
https://www.dropbox.com/s/f1c0lvtdtrlh5 ... esized.PSD

Re: Resize failing for transparent images on IM 6.5.4-7

Posted: 2014-02-05T11:10:14-07:00
by fmw42
This is the way IM handles PSD files with background transparency. It currently only used alpha channel transparency in PSD files. This has been reported and is being looked into. But most likely, there will not be any backward compatibility changes.

The only way I know now to handle it, is to open the psd file in Photoshop and convert to PNG or TIFF.

see
viewtopic.php?f=3&t=24905

Re: Resize failing for transparent images on IM 6.5.4-7

Posted: 2014-02-06T00:01:05-07:00
by Carter J
fmw42 wrote:This is the way IM handles PSD files with background transparency. It currently only used alpha channel transparency in PSD files. This has been reported and is being looked into. But most likely, there will not be any backward compatibility changes.

The only way I know now to handle it, is to open the psd file in Photoshop and convert to PNG or TIFF.
I don't think so. Please read the below lines that I mentioned in my first post
If watermark(psd) is not resized, the watermark is getting applied without any issue
composite -dissolve 40% -gravity center Watermark.PSD[0] OriginalImage.jpg. OutputImage.jpg

Re: Resize failing for transparent images on IM 6.5.4-7

Posted: 2014-02-06T00:28:51-07:00
by snibgo
Carter J wrote:convert -resize 1875x2500 Watermark.PSD[0] Watermark_resized.PSD
You are using PSD as in intermediate format. Any particular reason? I would use PNG. Test it to ensure it has the transparency you expect.

Re: Resize failing for transparent images on IM 6.5.4-7

Posted: 2014-02-06T03:02:24-07:00
by Carter J
snibgo wrote:
Carter J wrote:convert -resize 1875x2500 Watermark.PSD[0] Watermark_resized.png
You are using PSD as in intermediate format. Any particular reason? I would use PNG. Test it to ensure it has the transparency you expect.
Thanks, that worked
But any specific reason why ImageMagick is not able to handle PSD files

Re: Resize failing for transparent images on IM 6.5.4-7

Posted: 2014-02-06T08:46:56-07:00
by mrmattnc
PSD files are proprietary to Adobe - which would be my guess as to their varied support.

For what it's worth I would use the internal MPC format for intermediate steps to avoid compressing multiple times using multiple algorithms, or consider using an API and keeping everything in-memory.

Lastly, your watermark doesn't seem terribly complex -- you could do a semitransparent box and words directly inside IM, which would give you additional options on adjusting to varied image sizes. Just some options.

Re: Resize failing for transparent images on IM 6.5.4-7

Posted: 2014-02-06T11:15:07-07:00
by fmw42
This is very strange. I do not see how any part of your commands are working.

Code: Select all

convert watermark.PSD[0] watermark.png
Neither the PSD file nor the png file show any transparency on my 6.8.8.4 Q16 Mac OSX system either via display or via identify -verbose image. It is behaving as I said before, at least for me, as if IM does not recognize the background transparency in the PSD file.

Also you can combine both your commands into one command by using convert rather than composite and using parenthesis processing.

Code: Select all

convert OriginalImage.jpg \( Watermark.PSD[0] -resize 1875x2500 \) -gravity center -define compose:args=40 -compose dissolve -composite OutputImage.jpg
But I still get 40% white background showing in the watermark area rather than full transparency, because IM does not see the background transparency and just uses white.

If on Windows, the use (...) rather than \(...\)

PS I went back to IM 6.7.5.5 (as far back as I can go) and the above command works just fine. No white is showing around the red letters. So at some point there was a change to reading PSD files and IM could read the background transparency. However, I think, this is to be fixed in IM 6.8.8.5. see viewtopic.php?f=3&t=24905

A further test of available versions shows that the change occurred first at IM 6.8.8.1

Re: Resize failing for transparent images on IM 6.5.4-7

Posted: 2014-02-06T12:26:31-07:00
by snibgo
I'll expand my comment: for temporary files I'd use PNG for development, and MIFF or MPC for production. PNG is readable by Gimp and common image viewers so it's easy to check the results are as expected. When it works, I switch to MIFF (for small images) or MPC (for large images), and test again. MIFF comes with or without compression. I "-compress none", but I haven't done speed trials.

PSD is not a widely supported format, and Adobe have only recently published the format, and I don't have Photoshop.

Re: Resize failing for transparent images on IM 6.5.4-7

Posted: 2014-02-07T03:59:58-07:00
by Carter J
fmw42 wrote: A further test of available versions shows that the change occurred first at IM 6.8.8.1
Yes, it used to work in the earlier versions. Hopefully it will be fixed in IM 6.8.8-5

Re: Resize failing for transparent images on IM 6.5.4-7

Posted: 2014-02-09T23:38:07-07:00
by Carter J
fmw42 wrote: PS I went back to IM 6.7.5.5 (as far back as I can go) and the above command works just fine. No white is showing around the red letters. So at some point there was a change to reading PSD files and IM could read the background transparency. However, I think, this is to be fixed in IM 6.8.8.5. see viewtopic.php?f=3&t=24905

A further test of available versions shows that the change occurred first at IM 6.8.8.1
Issue reproducible with IM 6.8.8.5

Re: Resize failing for transparent images on IM 6.5.4-7

Posted: 2014-02-10T05:08:20-07:00
by dlemstra
It will be fixed in IM 6.8.8.6. There was a bug in writing the PSD file.