transparency question - large files

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
russellbarnhart

transparency question - large files

Post by russellbarnhart »

im trying to convert an image that has a transparent background:
Image
http://www.itsalmostreal.com/test.png

and replacing the background with solid white like:
Image
http://www.itsalmostreal.com/done.png


i'll be operating on huge files (44inches x 80inches @ 300 dpi) so im trying to do this using a method other than the following ones, because they forever on large files:

Code: Select all

 convert test.png -flatten done.png 

Code: Select all

 convert -size 1500x1500 xc:white test.png -geometry +0+0 -composite done.png 
whenever i try to kill the transparency, using either of the two following examples, the area that was transparent becomes black.

Code: Select all

convert test.png -alpha off done.png

Code: Select all

convert test.png -alpha reset done.png
i also already tried this, but for some reason it doesnt work either

Code: Select all

convert test.png -transparent-color white -alpha off done.png

in short i need a quick way to make sure that all apps see the background as being white, and not black. the input image (test.png) is a product of converting a layered PSD to flat TIFF conversion using Apple's SIPS. i ran into problems loading large layered psd files (anyone know how to load the composite image in PSDs?), so i had to use something to convert them to a format i can use with IM (flat TIFF files).

i guess the quyestion im asking is... is there a way to remove set all transparent space to the color white without actually processing each pixel? can the image header be modified to do the deed?

thanks for any help!

im using -> ImageMagick 6.3.7 02/19/08 Q16 on Ubuntu Server 8.04
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: transparency question - large files

Post by magick »

Composite your image on a white background:
  • convert -size 300x300 xc:white test.png -compose over -composite new.png
If the command fails, you may need to update your version of ImageMagick.
russellbarnhart

Re: transparency question - large files

Post by russellbarnhart »

can the image header be modified to do this instead of processing the pixel data?

i want to change
Alpha: none #00000000
to
Alpha: rgba(255,255,255,1) #FFFFFF00

can i do that without having to load ALL the image data?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: transparency question - large files

Post by fmw42 »

try

convert test.png -channel RGBA -fill white -opaque none done.png

or

if not solid white background then

convert test.png -channel RGBA -fuzz 5% -fill white -opaque none done.png

play with the 5% value until you get what you want.
Post Reply