At a high density like 300 dpi other than the default density 72 dpi the following ImageMagick convert command outputs blank pages. It looks strange to me.
"convert -units PixelsPerInch -density 300 $myfiles -page A4 -gravity center test.pdf"
Anyone like to exchange idea?
gravity parameter here isn't effective appropriately
(unable to align the object)
as it can't recognize the position & resolution of A4 page at 300 dpi. This is why the questioned command is outputting blank pages at 300 dpi.
We should avoid using page parameter if density is already defined. ImageMagick has a parameter called extent that can be used to define the resolution of a page at a given density (here 300 dpi). Thus we should use extent instead of page in this case in order to achieve the desired output.
For example,
resolution of A4 size page at 300 dpi is 2480x3508, thus correct command for a set density like 300 dpi shall be:
"convert -units PixelsPerInch -density 300 $myfiles -gravity center -extent 2480x3508 test.pdf"
Here, resolution of extent parameter should be proportionately equal to the set density for any specific page size.
Related
I am using the following command to convert the first page of a pdf to a png:
convert -density 200 "somePdf.pdf[0]" -size 500 "newImage.png"
But the output image size is not 500 pixels wide (it comes to over a 1000 pixels wide).
How do I define a specific output size?
You just use -density. In your Imagemagick command, don't use -size, and don't use -geometry. The density is what controls the output. Default PDF will use 72 dpi. So that is natural size for the dimensions converted from inches. If you want a specific size, make the density larger than needed and then use -resize.
convert -density 288 "somePdf.pdf[0]" -resize 500x "newImage.png"
You don't use size. You use geometry:
convert -density 200 "somePdf.pdf[0]" -geometry 500 "newImage.png"
This will specify the output width. You can also use -geometry 500x1000 to specify a specific width and height.
PDF does not concern itself with density or resolution just width and height. So to extract a page as image you say extract 594 wide page as 594 points 210 mm or 8.25 inches and its as perfect as the source ratios. ImageMagick does not convert PDF it passes the command on and its easier to use GS and several methods including GS support answer https://stackoverflow.com/a/10024458/10802527
If you wish to modify the returned pdf output as a different image you use IM convert to suite your taste but its not as accurate or clear as using pdftopng or better extract scanned pages as source dimensions then rescale
I am trying to use montage to print proxies for a card game I am developing (similar to Magic: the Gathering). I want the set the page size to letter, display four images per page, and have the images at 2.5 x 3.5 inches at 300 DPI.
I use the -page letter argument to get the right page size. I set -tile 2x2 so that I have four images per page. I set geometry +10+10 to get some space between the images.
However, montage resizes the images and they each take about 1/4 of a page, which is much bigger than what I want. I tried setting the pixels on geometry, for example, -geometry 744x1039+10+10 -density 300 which is 2.5 x 3.5" in 300 DPI, however, that did not work -- the image sizes remain the same.
How can I set the page DPI to 300 and the size of each image in the montage to 2.5" x 3.5"?
I'm using the following command to resize all the images in a folder:
convert folder\*.png" -format jpg -resize 1573 -quality 70 -strip -density 72 -interlace Plane -set filename:fname %t-1 +adjoin "C:\Users\%USERNAME%\Desktop\New folder\%[filename:fname].jpg"
It works, but instead of resizing to 1,573 pixels, I'd like to resize to 8.5 inches in width and 11 inches in height. How can I do that using ImageMagick Convert?
The "print size" of an image is the combination of its size in pixels and it print resolution, the matter being just metadata:
print size (inches) = size in pixels ÷ print resolution (in PPI)
So to change your image to 8.5×11 inches you can just change the resolution:
Necessary resolution = 1513 pixels ÷ 11 inches = 138PPI
The usual tool to edit metadata is ExifTool:
exiftool -xresolution=138 -yresolution=138 -v2 your_image.jpg
This of course assumes that your image is already in the 11 ÷ 8.5 aspect ratio. Otherwise you compute different X and Y print resolutions or first crop the image to achieve the proper aspect ratio.
Also, watch out for low resolution values. If you have text or sharp lines in the image (logo, CGI) 150PPI is on the low side...
If the page parameter is set, conversion of PDF files at a given density outputs blank pages.
"convert -units PixelsPerInch -density 300 $myfiles -page A4 -gravity center test.pdf"
If I omit page parameter from the command, I get appropriate output but at 72dpi default resolution.
Any idea?
A4 page size is 595 x 842. So in ImageMagick you could try
convert -units PixelsPerInch -density 300 $myfiles +repage -resize 595x842 test.pdf
That will make an A4 pixel dimension image with 300 dpi. You could also do
convert -units PixelsPerInch -density 300 $myfiles +repage -resize 595x842 -density XX test.pdf
Where XX is the dpi you want when printing the image of that size.
I added +repage to remove any input image virtual canvas, since you did not specify what format images you are using for $myfiles. Without +repage, that could have caused a large bit of white space at the top of your result.
Note it is always best and most helpful to provide your ImageMagick version and platform when asking questions about its use.
While I was trying to tweak the command I found that a set density (i.e, density 300) with a given page parameter actually sets the density of the -page A4 but not the converted object on page as the set density can't actually determine resolution of the -page A4 to which it shall be applicable. As a result, the command returns blurry or blank image on set page.
However, extent parameter is what, which actually outputs the appropriate image as it is possible to set the page resolution with this parameter at a predefined density. The following example will make it absolutely clear.
Resolution of A4 size page at 300 dpi is 2480x3508, thus correct command for a set density like 300 dpi shall be:
"convert -units PixelsPerInch -density 300 $myfiles -gravity center -extent 2480x3508 test.pdf"
Resolution of A4 size page at 72 dpi is 595x842, thus correct command for a set density like 72 dpi shall be:
"convert -units PixelsPerInch -density 72 $myfiles -gravity center -extent 595x842 test.pdf"
how can we make a tall-dynamicheight-screenshot.png into onefile.pdf with multiple pages in A4 so it could be readable when its printed?
example like this :
into A4 pages like
so when we print it would be like
not like (unreadable)
This is maybe good enough for a crude first approach - it doesn't look for good places (white space) to divide the pages along though, so it slices through the image at the bottom of your first page:
convert article.jpg -resize 2480x -crop 2480x3508 +repage result.pdf
In imagemagick you can crop to multiple pages. But it depends upon whether you want to keep your original size or resize the width to correspond to A4. The A4 file dimensions are 595x842.
If you want to keep the original dimensions and create a multipage PDF, then you will get 12 pages at your original resolution
convert V0twr.jpg -crop 595x842 +repage onefile1.pdf
If you want to resize to the width of an A4 and then crop, then you will get 2 pages at reduced resolution.
convert V0twr.jpg -resize 595x -crop 595x842 +repage onefile2.pdf
You can choose some other in-between resolution for your resize, if you want as a compromise, say twice the width of A4 = 2*595 = 1180