I have a YUV420 image of size 1280x720. I am trying to resize it to 720x576 using convert (Imagemagick) using below commandline options. But the generated output file doesnot seem to be a proper resized YUV420 image(I want the resized output also to be in YUV420 format):
convert -size 1280x720 -depth 8 -sampling-factor 2x2 test_1280x720_yuv420.yuv -filter lanczos -resize 720x576 -depth 8 -sampling-factor 2x2 720x576_yuv420.yuv //Here the output file size is not what it should be of a 720x576 YUV420 file which is 720x576x1.5 bytes.
Qiestion: What is the format of this output file then?
Also tried -sample option as, but same result. Incorrect sized output file. I even tried to display the generated resized file, but it sure is not a YUV420 file, as could not view it correctly at all.
convert -size 1280x720 -depth 8 -sampling-factor 2x2 test_1280x720_yuv420.yuv -sample 720x576 -depth 8 -sampling-factor 2x2 720x576_yuv420.yuv
Question: Would convert be able to do what I am trying to get done? IF yes, what are the options?
Question: Any other tool(freeware,shareware) which could help me resize YUV files(different formats YUV420, YUV444) to YUV format output files?
Try to ignore aspect ration!
Ignore Aspect Ratio ('!' flag)
If you want you can force "-resize" to ignore the aspect ratio and distort the image so it always generates an image exactly the size specified. This is done by adding the character '!' to the size. Unfortunately this character is also sometimes used for special purposes by various UNIX command line shells. So you may have to escape the character somehow to preserve it.
Example:
convert image.gif -resize 64x64\! resized_image.gif //Resized Image with ignore ratio option
Related
convert 0101.jp2 -threshold 50% -type bilevel -monochrome -compress LZW ../0101.tiff
The resulting image looks jagged when I use the above command to convert a colored scanned text page to a black/white image (must be one bit per pixel). I want to make it of a higher resolution to look smoother. How can I use convert to do so?
Note that SO automatically converts tif image to jpg format so the output image shown below is not the same as the output image. You will need to run the convert command to get the true output image in tif.
If instead of thresholding you apply a strong contrast the gray pixels on the edge remain in a range of grays and the output is not jagged.
convert Original.jpg -sigmoidal-contrast 30 Corrected.jpg
(there are several ways to increase contrast in Magick)
I have been working on an image from last 25 days with zero output. So I came here in search of an answer.
I have a jpg image of 7MB. I upload it in Photoshop and changed the width to 96 Inch, Resolution for 300 pixels/inch, checked resample option and selected Preserve Details 2.0 and reduce noise to 100%. It gave me a 1.5 GB image as output.
Now I tried the same steps in image magic
gm convert -scale 768 -units PixelsPerInch -density 300x300 -resample 300x300 -noise 100% image.jpg -resize 768 image.tiff
Above command gave output in KBs. I need help.
If you want a 96inch wide image at 300dpi, you will need a width of 28,800 pixels, so start with:
gm convert input.jpg -resize 28800x result.jpg
That will resize the image to the correct width and do whatever is required with the height to preserve the image's aspect ratio - i.e. without distorting it.
I am manipulating images using Image Magick. Here is the command that I use:
convert source.png -resize 1200 -quality 75 result.jpg
It works as expected. I am no wondering whether there is a way to report a conversion result showing how much compression has been done (in percentage or kilobyte or just by showing the sizes of original and converted images)?
I have tried -monitor switch, but it only shows a progress kind of report during conversion.
(I am using Linux)
The quality setting you use tells ImageMagick how much to compress the image. Alternately, you can compute the ratio of the output file size by the input size. Or the ratio of the output file size with -quality 75 to that when using -quality 100, even though -quality 100 still compresses some.
You can get the size of the image by
convert image -precision 16 -format "%b\n" info:
Setting a large precision will forces the result to be in Bytes, but you will have to remove the B character from the end. So you can do the following to get the percent of output/input file sizes:
outsize=$(convert output -precision 16 -format "%b\n" info: | sed 's/B//g')
insize=$(convert input -precision 16 -format "%b\n" info: | sed 's/B//g')
percent_size=$(convert xc: -format "%[fx:100*$outsize/$insize]\n" info:)
I've read the ImageMagick documentation here and here and been unable to achieve a couple of simple tasks. Would appreciate any simple pointers or direction, or even commands I can execute that will work on Linux.
I want to convert any image-type (JPG, GIF, PNG, TIFF) to save to a PNG, losslessly, and as compressed as possible without any loss of quality. Ideally in 96 DPI so they look good in Retina screens.
To then take the above generated PNG and also resize it in specific sizes, with height and width specified.
What am I missing with the convert command?
If you want to convert a TIF, GIF or JPEG to PNG, the command is:
convert image.tif result.png
or
convert image.jpg result.png
In answer to your questions...
Question 1
PNG is lossless by definition, so that is not an issue. To get better compression of a PNG, you generally need to reduce the colours, i.e.
convert image.jpg -colors 64 result.png # or try 255 which allows a palettised image
The dpi is pretty irrelevant until you print on paper. More pixels are needed if you want more quality on screen.
Question 2
If you want to resize an image without destroying its aspect ratio, use
convert image.jpg -resize 200x100 result.png # retain aspect ratio
If you don't care if that makes the image look stretched or distorted, and you want exactly 200x100, tell ImageMagick that you really mean it by shouting:
convert image.jpg -resize 200x100! result.png # ignore aspect ratio
I have a .eps file that I can look at in Photoshop, and it has a very high resolution, sharp edges, etc. at even larger than 1024x1024.
With ImageMagick I want to convert this .eps to a 1024x1024 .jpg with very high resolution.
However, with the following command, the image is very blurry:
convert -resize "1024x1024" -colorspace RGB -flatten test.eps test.jpg
What ImageMagick parameters do I have to use so that the resulting .jpg is 1024x1024 and a high quality, sharp image?
here's some XMP data we found, perhaps what is causing it to not be resized with -size:
For vector graphics, ImageMagick has both a render resolution and an output size that are independent of each other.
Try something like
convert -density 300 image.eps -resize 1024x1024 image.jpg
Which will render your eps at 300dpi. If 300 * width > 1024, then it will be sharp. If you render it too high though, you waste a lot of memory drawing a really high-res graphic only to down sample it again. I don't currently know of a good way to render it at the "right" resolution in one IM command.
The order of the arguments matters! The -density X argument needs to go before image.eps because you want to affect the resolution that the input file is rendered at.
This is not super obvious in the manpage for convert, but is hinted at:
SYNOPSIS
convert [input-option] input-file [output-option] output-file
Maybe you should try it with -quality 100 -size "1024x1024", because resize often gives results that are ugly to view.