Hi, I've been looking for some way to save the number or rows and columns (high and width) of the image as variables to use them in some "for" loops, but the closer I've get has been just saving all the information of the image in a file .txt.
Any help, please?
Save the size of the image as variables
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Save the size of the image as variables
In command line unix
size=`convert image -format "%wx%h" info:`
convert -size $size xc:red redimage.png
see http://www.imagemagick.org/script/escape.php
or
width=`convert image -format "%w" info:`
height=`convert image -format "%h" info:`
convert -size ${width}x${height} xc:red redimage.png
If on Windows, then see http://www.imagemagick.org/Usage/windows/
size=`convert image -format "%wx%h" info:`
convert -size $size xc:red redimage.png
see http://www.imagemagick.org/script/escape.php
or
width=`convert image -format "%w" info:`
height=`convert image -format "%h" info:`
convert -size ${width}x${height} xc:red redimage.png
If on Windows, then see http://www.imagemagick.org/Usage/windows/
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Save the size of the image as variables
If you just want the image to be red why not just make it red.
The -strip is optional, but you get the idea.
See IM Examples, Canvas Generation, Blanking existing images.
http://www.imagemagick.org/Usage/canvas/#blank
Code: Select all
convert image -strip -alpha off -fill red -colorize 100 redimage.png
See IM Examples, Canvas Generation, Blanking existing images.
http://www.imagemagick.org/Usage/canvas/#blank
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Save the size of the image as variables
anthony wrote:If you just want the image to be red why not just make it red.The -strip is optional, but you get the idea.Code: Select all
convert image -strip -alpha off -fill red -colorize 100 redimage.png
See IM Examples, Canvas Generation, Blanking existing images.
http://www.imagemagick.org/Usage/canvas/#blank
He did not ask for a red image. I just used that as a simple example of using the size after it was computed.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Save the size of the image as variables
Applogies.
prehaps we should ask... What does he want the size for?
Or more specifically What is the final objective!
prehaps we should ask... What does he want the size for?
Or more specifically What is the final objective!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Save the size of the image as variables
Hi, I wanted to save the size of the image as variables to use them to scan the image, to count how many pixels had a specific color. However I found an easier solution in this forum, so in the end I didn't use that way...
Thanks anyway!!
Thanks anyway!!