for f in *.jpg; do echo $f; mogrify -resize 64x64\! -set colorspace Gray -separate -average $f; done
i.e. some stuff and junk about Python, Perl, Matlab, Ruby, Mac X, Linux, Solaris, ...
Showing posts with label imagemagick. Show all posts
Showing posts with label imagemagick. Show all posts
Monday, December 19, 2022
ImageMagick: resize and ignore aspect ratio
Labels:
imagemagick
Wednesday, June 21, 2017
ImageMagick: montage images into one
montage -label '%f' -geometry +4+4 -pointsize 20 -tile 4x6 *.tiff mtg.jpg
Labels:
imagemagick
Tuesday, June 13, 2017
ImageMagick: Flatten image results in white image
Instead of -flatten option try using -layers trim-bounds
Labels:
imagemagick
Wednesday, May 10, 2017
ImageMagick: remove alpha channel from tiff images
mogrify -flatten -alpha off *.tiff
Labels:
imagemagick,
Linux
Tuesday, February 14, 2017
Imagemagick: bash split large images into smaller
for f in *.tiff ; do fbase=`echo $f | cut -d '.' -f 1`; echo $fbase; convert -crop 510x510 +repage $f sub/${fbase}_%02d.tiff ; done
Labels:
imagemagick
Wednesday, January 11, 2017
Imagemagick: Conver multiple pdf into image so that all pages are in one file for each pdf
mogrify -append -format png -density 200 -alpha remove *.pdf
Labels:
imagemagick,
Linux
Friday, November 04, 2016
Thursday, March 10, 2016
ImageMagick: Crop images in half verticly
Left half
mogrify -gravity West -crop 50%x100%+0+0 *.tiff
Right halfmogrify -gravity East -crop 50%x100%+0+0 *.tiff
Labels:
imagemagick,
Linux
Wednesday, January 06, 2016
ImageMagick: remove alpha and flatten
mogrify -flatten -type Grayscale -alpha remove *.tiff
Labels:
imagemagick
Wednesday, November 05, 2014
Ubuntu: pdf to images and images to pdf
pdftoppm -png a_pdf_file.pdf img
convert *.png a_pdf_file_as_img.pdf
Labels:
imagemagick,
Ubuntu
Monday, August 04, 2014
ImageMagick: resize images to specific width or hight
For example to resize tif images to width of 512 pixels:
Whereas to resize tif images to height of 512 pixels:
mogrify -resize 512 *.tif
Whereas to resize tif images to height of 512 pixels:
mogrify -resize x512 *.tif
Labels:
imagemagick
Sunday, July 20, 2014
Imagemagick: Flattening tiff images
mogrify -alpha off -colorspace gray -depth 8 -flatten *.tiff
Labels:
imagemagick
Thursday, June 26, 2014
Reading DICOM files in Python 3
In Python 3, dicom files can be read, analysied and processed using Wand which is Python binding for ImageMagic. The example below shows how to get medical and image date embedded in DICOM and also how to disply the image itself.
Labels:
imagemagick,
Python,
Wand
Tuesday, June 10, 2014
ImageMagick: get size and resolution (DPI) of images
To get size and resolution in DPI of many images at once using ImageMagick, we can use this command:
identify -format "%w x %h %x x %y\n" *.tiff
This result for example in:576 x 432 72 PixelsPerInch x 72 PixelsPerInch
576 x 432 72 PixelsPerInch x 72 PixelsPerInch
576 x 432 72 PixelsPerInch x 72 PixelsPerInch
576 x 432 72 PixelsPerInch x 72 PixelsPerInch
576 x 432 72 PixelsPerInch x 72 PixelsPerInch
576 x 432 72 PixelsPerInch x 72 PixelsPerInch
Labels:
imagemagick
Wednesday, August 28, 2013
ImageMagick: batch resize and DPI change
mogrify -resize 59.06% -density 150x150 *.tif
mogrify -resize 1024x1234 -density 150x150 *.tif
If the images are in grayscale than the above will convert them to RGB. Thus one can use the following:
mogrify -resize 59.06% -density 150x150 -colorspace gray -layers flatten *.tif
mogrify -resize 1024x1234 -density 150x150 -colorspace gray -layers flatten *.tif
Labels:
imagemagick
Wednesday, March 30, 2011
ImageMagick: Make thumbs of images
For example to make jpg thumbs of all tiff images in a current director one can use:
for f in *.tiff; do bname=`basename $f .tiff` ; convert -resize 256x256 $f ./thumbs/$bname.jpg; done
Labels:
imagemagick
Thursday, March 17, 2011
ImageMagick: Flatten and convert an image to grayscale
In short, to flatten and convert to grayscale all images in current director one can use:
mogrify -flatten -type Grayscale *
or mogrify -flatten -alpha remove *.tiff
Labels:
imagemagick
Wednesday, March 03, 2010
imagemagick: crop all images
Example:
convert rose: -crop 40x30+10+10 +repage repage.gif
Labels:
imagemagick
Thursday, February 18, 2010
ImageMagick: split one image to smaller images
Lets assume that we have a 1024x1024 pixel image called test.tif and that we want to split this image into 64x64 non-overlapping images called test001.tif, test002.tif, test003.tiff,....
We can do this using this command from
We can do this using this command from
convert -crop 64x64 +repage test.tif test%02d.tif
Labels:
imagemagick
Monday, October 19, 2009
How ImageMagick can save you time
ImageMagick is a great tool! Many times it has saved me from programming. Here is just one example of many applications of the ImageMagick that can save one's time.
Recently, I was asked to check whether a set of images (few hundreds of them) contains one particular image. So, basically I was given and image (called testImage.tiff), and I needed to check whether this image belongs to a set a few hundreds of images. En example of the images from the set is below:
So how to anwser this? You can do manual (i.e. visual comparison), you can also write some simple script in Python with PIL. All would take some time. But why to do this, if you can just write one for loop in bash with compare command from ImageMagick?
So first thing I did is to create the following folders:
The input folder contains all images from the set, the output folder will be where the results of my search will be stored, and the testImage.tiff is my test image.
As can be seen in the above picture, the testImage.tiff belongs this this set.
One limitation of this procedure is that I had to manually go through the output folder. But because all not matching images are in red, it was very quick to find, the one image that was not red. (if any). Additionally, if the testImage.tiff and images from the set were of different size or type additional code would be necessary.
So thanks to the ImageMagick, I could do the job in just a few minutes.
So first thing I did is to create the following folders:
The input folder contains all images from the set, the output folder will be where the results of my search will be stored, and the testImage.tiff is my test image.
So thanks to ImageMagick's, the only thing I had to do is to execute its compare command on all images from the set (i.e. input folder). In other words, I compared, in a loop, an image from the set with the testImage.tiff and the results of the comparison went to output folder. Below is the bash for loop that was executed inside the input folder.
for f in *.tiff ; do
compare $f ../testImage.tiff ../output/$f ;
done
After loop finished, I could go to output folder, and quickly find out whether testImage.tiff is in the set:As can be seen in the above picture, the testImage.tiff belongs this this set.
One limitation of this procedure is that I had to manually go through the output folder. But because all not matching images are in red, it was very quick to find, the one image that was not red. (if any). Additionally, if the testImage.tiff and images from the set were of different size or type additional code would be necessary.
So thanks to the ImageMagick, I could do the job in just a few minutes.
Labels:
imagemagick
Subscribe to:
Posts (Atom)