Code: Select all
convert buffer.png -extent YxX
Is there a command for this?
Code: Select all
convert buffer.png -extent YxX
You can use "-splice" to add a row of a particular width to just one side of an image. Something like...chaoscarnage wrote:I do not know if I can use crop and just give it negative numbers.
Is there a command for this?
Code: Select all
convert image.jpg -background white -gravity northwest -splice 20x0 result.jpg
Here is a more detailed example of what I am trying to do. I figure if I learn how to pad one side, I can pad all sides the amount I desire.GeeMack wrote: You can use "-splice" to add a row of a particular width to just one side of an image. Something like...
... would add a 20 pixel wide white row to the left side of the image. By setting "-background" and "-gravity" you can add any amount of any color to any one side (or any two adjacent sides) of the input image. Read more about it at this LINK.Code: Select all
convert image.jpg -background white -gravity northwest -splice 20x0 result.jpg
There are several ways to go about this sort of thing. You can create an empty canvas the size you want your finished image, set the geometry of the input image to the location you want it on that background, then composite the input image onto the canvas. A command to do that might look something like this...chaoscarnage wrote:Here is a more detailed example of what I am trying to do. I figure if I learn how to pad one side, I can pad all sides the amount I desire...
Code: Select all
convert input.jpg -geometry +50+30 xc:white[400x400] +swap -composite result.jpg
Code: Select all
convert input.jpg -background white -gravity northwest -splice 50x30 -extent 400x400 result.jpg
Code: Select all
convert input.jpg -background white -gravity northwest -splice 50x30 -extent 400x400 result.jpg
ImageMagick can work with stacks of images, not just single images. In that command I brought the input image in first, then I built the 400x400 white canvas second. That's their order in the stack. The "+swap" trades places of the last two images in the stack (or the only two images in this case) so the input image gets composited on top of the background canvas. Without that "+swap" the background would have been layered over the input image (... although there are many other ways to rearrange the order of the stack and composites, too! )chaoscarnage wrote:What does +swap do?
Yes, you can make a canvas of any color, even transparent (none), but of course it will only be transparent for output formats that support it like PNG.chaoscarnage wrote:Also, if I want the xc to be none instead of white, will that work?
You know more about this then I do. I received an answer on stackoverflow. However... What I am doing is a lot more complex then what I have lead on. I am wondering if I can convert what I have into their answer and see if its faster. (I am doing 250 images at once and right now it takes 17.9 seconds to complete).GeeMack wrote:ImageMagick can work with stacks of images, not just single images. In that command I brought the input image in first, then I built the 400x400 white canvas second. That's their order in the stack. The "+swap" trades places of the last two images in the stack (or the only two images in this case) so the input image gets composited on top of the background canvas. Without that "+swap" the background would have been layered over the input image (... although there are many other ways to rearrange the order of the stack and composites, too! )chaoscarnage wrote:What does +swap do?
Yes, you can make a canvas of any color, even transparent (none), but of course it will only be transparent for output formats that support it like PNG.chaoscarnage wrote:Also, if I want the xc to be none instead of white, will that work?
Code: Select all
exec('convert ' . $img . '.png /gradient/gradient.png -clut -background none -splice ' . $test[0] . 'x' . $test[1] . ' -extent 400x400 ' . $img . $r);
Code: Select all
convert -size 400x400 xc:lime \( 52x107.png -repage +158+146 \) -flatten out.png
It is always better to say what you want in the first place rather than "start with something simple" and keep increasing the complexity.What I am doing is a lot more complex then what I have lead on.
chaoscarnage wrote:
How do I do this in command line
rose: rose-over.png
Then use rose in my convert.
Code: Select all
convert rose: ...some commands... rose_processed.png
Code: Select all
convert rose: rose.png
What I was wondering is if I used the same image 10 times, would it be better to first copy it so it does not have to load that initially image 10 times.fmw42 wrote:chaoscarnage wrote:
How do I do this in command line
rose: rose-over.png
Then use rose in my convert.
It is not clear what you want.
To use the rose: image, just use it. You do not have to rename it first.
If you want to make a copy of the rose: image, you can do it in IM asCode: Select all
convert rose: ...some commands... rose_processed.png
But there is no reason to copy it, since IM does not destroy the input image.Code: Select all
convert rose: rose.png