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.
Convert a file to match exact attributes of another file?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert a file to match exact attributes of another file
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?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.
Re: Convert a file to match exact attributes of another file
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?
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?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert a file to match exact attributes of another file
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
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
Thanks!
I'd already started a script and thought that this might already be done. I'll continue on that route.
Regards.
I'd already started a script and thought that this might already be done. I'll continue on that route.
Regards.