Image magick (windows) - How do I perform batch resizing for several images type in a folder? - imagemagick

How do I perform batch-resizing for many images in a folder?
for example I have 4 images in folder C:\tried
image1.jpeg
image2.png
image3.bmp
image4.tiff
and I want to
1. convert them to JPG
2. resize them to 575px
3. lower the quality of each image to 90%
4. move them into different folder
5. delete every picture that converted
Can I do this using batch file (*.bat) in Windows?
start from number 1,

There are plenty of examples on Stack Overflow:
magick mogrify -path OUTPUTDIRECTORY -format JPEG -resize 575 -quality 90 *.tif *.jpg *.bmp
You'll have to delete them yourself.

Related

Image magic convert command creates more than one file

I executed below command to convert a .tif file to a .jpg file. But for some tif images it generates 3 jpg files when only one file is expected. One is the expected jpg file, one is the same image in a black background and the other is just a white image.
magick convert /<.tif image name> -intent relative -resize 1500x1500> -quality 95 -colorspace sRGB -strip -auto-orient /<output .jpg image name>
Does anyone know the reason for this? what property of the input file causing this? or is there a issue with the command?
magick convert /<.tif image> -intent relative -resize 1500x1500> -quality 95 -colorspace sRGB -strip -auto-orient /<output .jpg image>
Expect this to give a single jpg image. But it gives 3 images for some input .tif images
Just adding some meat to #GeeMack's comment...
TIFF files often contain multiple images - or IFDs as referred to in the documentation. These can represent many things, but the most common are:
a low-resolution, flattened preview image followed by a full-resolution image aimed at providing quick previews
multiple pages of longer documents
colour separations for printing
the many channels of multi/hyper-spectral images
the layers of a multi-layer images, e.g. Photoshop editing layers
images and their associated masks, or classes/categories/classifications
... and so on.
A quick way to check what you have is with ImageMagick's identify command as that will produce a line for each image in the file, and you can often tell by the sizes, shapes and types of the layers which is a small preview and which is high resolution image, or that there are 242 channels of identical resolution images for a EO-1 hyperspectral imager.
magick identify IMAGE.TIF
Here's an example:
magick identify Prokudin-Gorskii.tif
Prokudin-Gorskii.tif[0] TIFF 3702x3205 3702x3205+0+0 16-bit sRGB 134.955MiB 0.060u 0:00.064
Prokudin-Gorskii.tif[1] TIFF 3702x3205 3702x3205+0+0 16-bit sRGB 134.955MiB 0.000u 0:00.001
Prokudin-Gorskii.tif[2] TIFF 625x175 625x175+841+814 16-bit sRGB 134.955MiB 0.000u 0:00.001
and you can see from the sizes that there are two full layers followed by a reduced size layer that is only annotation or markup on a small area of the image.
Another useful technique is to lay out all the images within a TIFF beside each other in a row across the page, with 10 pixel gaps between, using a command like this:
magick IMAGE.TIFF +smush 10 contents.jpg
We can now see that the three layers in the foregoing image correspond to a flattened version of all the layers on the left, followed by the two individual layers themselves in the centre and the reduced size yellow line overlay layer on the right.
If we then determine that it is only the first, flattened image we are interested in, we can extract and manipulate that alone by adding its sequence number in square brackets afterwards. So, to extract just the first flattened image:
magick IMAGE.TIF[0] extracted.tif
You can also extract multiple individual images and ranges, using commas and dashes.
Note also that magick convert is generally not what you want.
Note also that exiftool is lighter weight than a full ImageMagick installation and can also tell you what's in a multi-IFD TIFF.

ImageMagick v7 conversion of 8bpp images

On Windows 10, I need to crop and resize whole folders of images.
Following the documentation and some answers here i've built this batch:
magick mogrify -path ./cropped -crop 1300x1940+85+130 +repage -resize "800x800^" *.jpg
It mostly works, but when a folder has mixed image formats (some are 24bpp, some are 8bpp, grayscale) this batch skips all the 8bpp ones.
How can i change my command so it accepts and modify every image, no matter what?
Note: i used mogrify as i understand it is needed to process a whole folder and save the result in another one, but i'm unsure it is necessary.

Any file type that can go over JPEG maximum resolution limit?

I am trying to combine multiple JPEG file into one single long file using this command
magick convert ..\galerry\*.jpg -gravity center -append longview.jpg
However while combining the files, imagemagick reached the limit of 65500 pixels
Is there any file format that can store image larger than 65500 pixels with the same compression as JPEG file format?

Poor quality output after merging multiple image into one using Montage of ImageMagick

I tried to merge multiple jpg images files into one jpg using magick montage -border 0 -tile 4x3 *.jpg outputfile.jpg but the image is very very poor quality.
How do I enhance the high-quality image or same quality image after merging all files into one?

ImageMagick convert issues

I have been using the batch method to convert any number of PDFs to any other format in any DPI (Best way to convert pdf files to tiff files).
ImageMagick was updated (I run ImageMagick-7.0.3-Q16), and I though the old command:
convert -density 300 -compress LZW testfile.pdf testfile.jpg
could just be changed to:
magick -density 300 -compress LZW testfile.pdf testfile.jpg
Both the 'density' and the 'compress' functionality appear in the new manual... It does create a jpg, however, the DPI is 96 (default?) and it seems that the actual dimensions of the figure increases a lot.
(The actual text in the .bat file is
for %%f in (%*) DO "C:\Program Files\ImageMagick-7.0.3-Q16\magick.exe" -density 300 -compress LZW %%f %%f.jpg
but the issue also appears when I run the simplified code above...

Resources