I am unable to change the geomentry of a bmp image.
I am using Imagemagick libraray in ubuntu.
I have a image with geometry 268*78 i want to convert it to 384*78. I am using the command convert out.bmp -monochrome -resize 384x78 out3.bmp. The command doesn't throw any error but the out3.bmp geometry doesnt change. can anyone tell me a way to change that.
From the imagemagick website:
widthxheight Maximum values of height and width given, aspect ratio
preserved.
Try:
widthxheight! Width and height emphatically given, original aspect
ratio ignored.
convert out.bmp -resize 384x78! -monochrome out3.bmp
Related
It seems that with potrace installed, I can just run magick convert x.png x.svg or magick convert x.jpg x.svg.However this just returns a deformed image in black and white, and I need the svg image to be in full color. Additionally, I really need the file format to be svg because svg images are small and portable, and I don't have a lot of disk space on my server.Does anyone know how to convert png/jpeg to svg while retaining color?
I've got a 16x512 image comprised of 16x16 images. I want to seperate them, individually scale each one down to 16x8, then put them all back into their full 16x512. I've got a basic idea, but I'm having trouble executing it.
Using the commands from unix stackexchange, I split by file by using convert -crop 16x16 my_image.png crop-%d.png, which yields 32 images (512 / 16 == 32). My next step was where trouble has started. From askubuntu, I found the command mogrify -resize 16x8 crop-*.png, however this does not yield 16x8 images, but rather 8x8, which I do not want. Furthermore, this post on stackoverflow gives me the command for merging these images, which is convert crop-*.png -append my_image_cropped.png, however it does not yield a 16x512 like I want, but rather 8x256 (the 8 is due to the previous bug, but I still want a height of 512, not 256).
What do I need to accomplish my goals? The image in question can be found on imgur.
Edit: Here are some images which will describe the basic idea
The full image:
Both 16x16 and 16x8 side by side
The finalized image, basically the 16x8 will sit in the 16x16 area (right at the bottom part, that is essential), but won't fully fill it.
I am not sure I understand what you want to do. But if you resize 16x8, Imagemagick will keep aspect ratio. If you want to force it to be exactly 16x8 and can accept distortion, then use the ! flag. But you then say you want to put the 32 pieces back to form 16x512, but the resize will make it 16x256, since you have 32 image of height 8. So you have to resize again. Here is how to do that, if that is really what you want.
Create a gradient image for testing:
convert -size 16x512 gradient: grad.png
Do the processing:
convert grad.png -crop 16x16 -resize 16x8! -append -resize 16x512! newgrad.png
Note that proper Imagemagick syntax reads the input first.
ADDITION:
Given your new information in your comment, try this:
convert grad.png -crop 16x16 -resize 16x8 -gravity northwest -background none -extent 16x16 -append newgrad.png
Change the background color as desired and the gravity setting as desired for positioning.
I want to resize image to an exact size by maintaining aspect ratio and filling the empty space with transparency using nodejs.
I am able to do it using canvas. But due to some server os issues I can not use canvas.
I tried with imageMagick and gm. But couldn't find any option like these. Please show me a way to do this.
Thanks in advance.
In ImageMagick, you can resize and fill to the exact size by
convert image -resize WxH -background none -gravity center -extent WxH output
Input:
Here I will make the background black so you can see that if fills it out.
convert lena.jpg -resize 400x300 -background black -gravity center -extent 400x300 lena1.jpg
In case you have been successful using the canvas for resizing images, you can check out https://github.com/Automattic/node-canvas this repo.
As already mentioned you also resize images using ImageMagick by processes in NodeJS ( http://www.imagemagick.org/Usage/resize/ )
convert dragon.gif -resize 64x64 resize_dragon.gif
In case you have a lot of images, I would suggest that you write a terminal script ( NodeJS can achieve that as well ).
I hope it helps, in case you have more queries, feel free to ask.
i try to convert an .eps File to .png with ghostscript.
The .eps file has a resolution of 1000x1000 px. But the outfile has big white borders on left and on the bottom side.
gs -dNOPAUSE -dBATCH -r1000x1000 -q -sDEVICE=png256 -dDEVICEWIDTHPOINTS=880 -dDEVICEHEIGHTPOINTS=720 -sOutputFile=infile.png infile.eps
EPS files don't have a resolution, so it cannot possibly have a resolution of 1000x1000, especially not 1000x1000 pixels, because that's not a resolution, its a size.
I very much doubt you want to set the resolution to 1000 dpi and at the same time set a media size of 880 points x720 points. That will result in a .png 12000x10000 pixels. (There are 72 points to the inch, which means you are setting a media of 12x10 inches at 1000 doits per inch)
The correct way to handle an EPS file (which is slightly but importantly different to a PostScript file) is to arrange the scaling yourself.
If the dimensions of the resulting image are not important to you, then you can use -dEPSCrop which will produce an image where the dimensions of the media are taken from the comments in the EPS file.
If you require that the image has specific dimensions then you should use -g to set the media size (in pixels), set -dFIXEDMEDIA and set -dEPSFitPage which will scale the EPS to fit the dimensions of the media.
I found the solution :
-dEPSCrop
Not sure what is causing that without seeing the eps file, but you can trim it off with ImageMagick like this:
convert SomeFile.png -trim result.png
ImageMagick is installed on most Linux distros and is available for OSX, and Windows.
I'm trying to create thumbs of an equal size, and I want no padding whatsoever. The thumb should be 154x208 pixels. The original can vary in shape and size.
I'm using ImageMagick, first I tried this:
convert org.jpg -thumbnail 154x208 dest.jpg
This will create a thumbnail that is maximum 154 pix wide AND maximum 208 pix of height. I want an image that is 154x208 pixels though. Without padding.
I tried this:
convert org.jpg -thumbnail x208 -crop 154x208+0+0 dest.jpg
This works great on an image in landscape mode, but a picture in portrait mode results in a thumb that's too narrow. -extent instead of -crop gives me the right end-result, but that ads padding to the thumbnail, and I don't want that.
I'm looking for a thumbnail from a picture that either has the full height and crops the width to fit, or the full width and crops the height, always resulting in a 154x208 thumbnail with no padding, using ImageMagick
I solved it by treating images with a smaller width-to-height ratio different from ones with a larger one:
a smaller width-to-height ratio than 154x200 image:
convert org.jpg -thumbnail 154 -gravity center -crop 154x200+0+0 dest.jpg
and a higher ratio:
convert org.jpg -thumbnail x208 -gravity center -crop 154x200+0+0 dest.jpg
It is an extra step in my coding, and I am still interested in an answer that doesn't need this extra step, but it does the job for now!