ImageMagick convert issues - imagemagick

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...

Related

How to restrict tiff file size using ImageMagick and python?

I am converting a pdf to .tiff file using ImageMagick and calling it from python using subprocess,run() but, I want the output file size to be limited to a maximum value say 40MB. -define extent max_value is not working for tiff like it works for jpeg images.
This is my code:
subprocess.run('magick convert -density 150 example.pdf -trim -thumbnail 500 result%04d.tif')

Why does imagemagick convert increases file-size

I am using ImageMagick to convert png files to tiff. But after conversion the file size seems to increase by a huge amount? Any suggestion on what am i doing wrong here?
Command that I am using for conversion is : convert tiftest1.png tiftest2.png output_file.tif
PNG files are analysed (filtered) on a line-by-line basis to see how best each line can be compressed relative to the previous one, then compressed. TIFF files, in general, are not.
You need to consider whether you can accept lossless or lossy compression and then tell the TIFF encoder.
If only lossless compression is acceptable:
magick input1.png input2.png -compress LZW result.tif
If lossy compression is acceptable (and compatible with downstream needs):
magick input1.png input2.png -compress JPEG result.tif
Check actual compression used in a file with:
magick identify -verbose image.tif
Check available types of compression with:
magick identify -list compress
When converting to tiff, ImageMagick produces a non-compressed file by default. You can tell it to use LZW or ZIP or JPEG or other compressions. PNG is always compressed.

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

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.

how to convert scanned jpg files to pbm format losslessly?

Using ImageMagick's convert utility to convert some scanned jpg files to pbm files.
However, even if the option -quality 100 is used, the pbm's resolution still looks worse than the original scanned jpg file.
Worse, the scanned jpg file is a colored one, while the converted pbm is black and white.
Info of original jpg:
image size: 2256 × 1568 pixels
dpi: 300 pixels/inch
color model: RGB
info of the converted pbm:
image size: 2256 × 1568 pixels
dpi: 72 pixels/inch
color model: Gray
Currently, here is what I did to convert the format:
qiang#bonjour:~/scan$ convert scan000.jpg scan000.pbm
Am I missing any option to use with convert? As I mentioned earlier, -quality 100 had been tried, but to no avail.
Using ImageMagick, I think you want to output to PPM not PBM. Try
convert image.jpg image.ppm
or try the ascii version by using
convert image.jpg -compress none image.ppm
PBM is binary (black/white) and PGM is grayscale. If you want to keep color, then you need to use PPM.
Unfortunately, I believe that ImageMagick can only read DJVU format images. So you cannot write to it directly from ImageMagick.

pink tif file made from ImageMagick

I am trying to send a tiff file through fax machine.
This file seems fine with image viewer and paint, but
my boss told me that while trying to send the tif file using fax program,
he's getting pink all over his background instead of white..
and 40 kb of tif file bumps up to 600kb while trying to send the tif file..
And I used ImageMagick converting from PDF to Tiff, and the command line I used was
"C:/Program Files/ImageMagick-7.0.3-Q16/convert.exe" -density 200 -resize 1728x2291 -monochrome -compress group4 D://fax_files/201612/20161208155410.pdf D://fax_files/201612/example/1.tif
the pink image is here..
Did I make any mistakes on using ImageMagick or are there any issues that cause the problem?
If you know any, please help me out..
Thank you in advance..
I believe that to fax a tiff, it has to be binary (black/white), not color and needs to be compressed with group 4 compression.
With PDF files you need to set the density and units before reading the input and all the other arguments afterwards.
So
convert -density XXX -unit YYY image.pdf -resize ZZZ -monochrome -compress group4 image.tif

Resources