Page 1 of 1
Convert a file to match exact attributes of another file?
Posted: 2010-02-23T14:06:47-07:00
by Markus5
I have a file which I would like to convert and scale to match the exact attributes of another file.
Is there a way to do that?
This is using Linux and shell scripting is OK.
I need to automate the conversion of a product logo image which will replace existing images of a wide variety of formats/sizes.
Regards.
Re: Convert a file to match exact attributes of another file
Posted: 2010-02-23T14:19:46-07:00
by fmw42
Markus5 wrote:I have a file which I would like to convert and scale to match the exact attributes of another file.
Is there a way to do that?
This is using Linux and shell scripting is OK.
I need to automate the conversion of a product logo image which will replace existing images of a wide variety of formats/sizes.
Regards.
Please clarify what you mean by match the exact attributes of another file? What attributes are you talking about? Can you provide links to samples of what you want to do?
Re: Convert a file to match exact attributes of another file
Posted: 2010-02-23T14:42:03-07:00
by Markus5
Say an existing file has these attributes:
PNG 570x236 570x236+0+0 8-bit DirectClass
There is a target file with these attributes:
PNG 302x110 302x110+0+0 8-bit DirectClass
I can pick out the attributes with a script and do something like
convert input.png -resize 302x110 output.png
And get a file with these attributes.
PNG 147x110 147x110+0+0 8-bit PseudoClass 32c
I can play with the options to get the output to match the original target file, but I'd like to automate that as much as possible. Distorting the image or filling the output image are both acceptible.
And, what is PseudoClass?
Re: Convert a file to match exact attributes of another file
Posted: 2010-02-23T16:26:27-07:00
by fmw42
You basically need to extract the attributes you are looking for from identify or identify -verbose (or use some of the string formats, see
http://www.imagemagick.org/script/escape.php), put them into variables and then write a script with the relevant options and variables as arguments in your command line.
Pseudoclass means 8-bit colormap (8-bits per pixel and not 8-bits per channel) it is set by using -type palette, see -type
http://www.imagemagick.org/script/comma ... s.php#type
Directclass means 8bits per channel and is set with -type truecolor
Re: Convert a file to match exact attributes of another file
Posted: 2010-02-24T07:40:25-07:00
by Markus5
Thanks!
I'd already started a script and thought that this might already be done. I'll continue on that route.
Regards.