PNG Transparency

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

The bug is in IE. Upgrade to IE 6 (or is it 7) Beta and it will render your PNG images correctly.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Post by glennrp »

magick wrote: The bug is in IE. Upgrade to IE 6 (or is it 7) Beta and it will render your PNG images correctly.

IE7rc1 will render the PNG transparency correctly. There's still a problem with gamma, that is solved by using the PNG sRGB chunk without a gAMA chunk.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

When converting from PDF or PS formats IM uses Ghostscript. Unfortunatally it needs help when you want to preserve transparency from such file formats...

See the recent forum note for postscript...
Converting EPS to transparent GIF part 3
http://redux.imagemagick.org/discussion ... php?t=7366

For full details and solutions.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

Looking in the delgates.xml file, It looks like PDF is converted to PS then PS is converted to images.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

While I have not had the 'pleasure' (sic) of modifing delegate code, though I plan to for the documenting of IM examples, that does NOT look right to me.

The previous code generated 'eps' which is what the delegate declares will be returned.
The new one returns a transparent alpha, but still declares it generated 'eps'.

I suggest you check it and update.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

With "type.xml" in your home ".magick" sub-directoyr you can append your own fonts to the system font list, I would like to know if you can do the same, or even override the system version using a "delegate.xml" in that same home sub-directory.

Christy can you help shead light on this?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

For security reasons you cannot override the system installed ImageMagick delegates. You can add unique delegates in ~/.magick/delegates.mgk but any duplicate delegates are ignored.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

Thanks Chrisy.

How does IM determine if a delegate is unique, and how does it pick between
say a "pdf -> png" and the system "pdf -> eps" delegates?

Eg will adding a "pdf -> png" delegate cause it to be used as it is more direct?

Can you specify 'alturnate' input/output format delegates?

For example can we specify a delegate to decode a "pdf2png" format image EG:

Code: Select all

<delegate decode="pdf2png" encode="png" mode="bi" command=""gs" -q -dBATCH -dSAFER -dMaxBitmap=500000000 -dNOPAUSE -dAlignToPixels=0 -sDEVICE="pngalpha" -sOutputFile="%o" -f"%i"" />
in your personal "delegates.mgk" file then use...

Code: Select all

  convert  -density 300x300  pdf2png:file.pdf ...
to use your own delgate method?

WARNING: delegate does not pass any "density" settings to ghostscript!!!!

If this works then "Tonytt98" can create his own delegates, seperate to the system degegates and will not need to effect other users on the system.

I will add this to the IM examples 'Image File Handimg' section, if I can get verification that it works.
Last edited by anthony on 2006-09-20T23:03:58-07:00, edited 1 time in total.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

If you need to have different delegates than what is installed on the system, the only current solution is to install your own private version of ImageMagick that will pick up your delegate.xml file rather than the system version.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

That is not what he refered it. Look at my last post above (end of page 1) about adding a new delegate for a "pdf2png" input image type. I'd like to know myself for IM Examples.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

ImageMagick only consults the delegates if the image format is not supported internally. Since PDF is, ImageMagick would never fire the png2pdf delegate. However, you could override this behavior with an an explicit custom tag. Lets declare a new image format called custom. First we edit delegates.xml and add
  • <delegate decode="custom" command='"pdf2png" "%i" "%o"' />
To activate, use this command:
  • convert custom:image.pdf image.tif
for example. Note we have not tested this so if it fails for some reason, post here and we'll take a closer look at the problem.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

Thank you, that was what I was asking.
<delegate decode="pdf2png" ....>
then
convert pdf2png:image.pdf ....
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

The above should work and you should be able to add it to your personal delegates.xml file in your home. It should not interfer with the system delegates as you finded a new 'input image format' called "pdf2png".

If this does not work we have a bug.

NOTE: the above does not pass any density or resolution options to GS, it is an example only at this point.

let us know how it goes.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

The PDF/PS delegates are in a special format used internally. For PDF we use the ps:color delagate rather than ps:alpha because the pngalpha device only supports one page/one image and PDF's generally are multi-page and ImageMagick requires the delagate to return a multi-frame image format. If you use pdf2png you would need to concatenate all the PNG images into a multi-image format such as MNG, MIFF, TIFF, etc. For an example, see the pov delagate. You might be better off using Ghostscript directly and bypassing ImageMagick if you are attempting to get transparent PDF images.
Post Reply