Page 2 of 2
Re: Copy and paste regions
Posted: 2010-10-07T05:46:20-07:00
by anthony
resize has no location, it just resizes the image to the pixel sizes specified, or to the percentage specified.
So you need to do things step by step
- read the image
- crop (and +repage) the part of the image wanted
- resize to the new size in pixels
- set a geometry position
- read destination image
- swap two image so the croped image is second (overlay) image
- set a geometry position
- compose the two together
- save the result
You can reorder operations by using parenthesis to do things 'on the side' but essentually the above is all the steps needed.
The steps can be modified for non-rectangular areas (masking instead of cropping, or for warping and distorting the image into a new shape or location before overlaying, but essentually the same basic steps should be followed.
You can break up the steps into separate commands, or insert other modifications, but the basic steps remain.
NOTE : we are not here to do the work for you, bt help and guide you to the best solution. With actual examples we can generate actual commands, but it is better if you actually understand what individual steps should be taken.
Re: Copy and paste regions
Posted: 2010-10-07T09:39:18-07:00
by fmw42
galv wrote:Fred, if I'm not mistaken that resizes the image to half. Which is not what I want.. :/
Anthony, how? How do I specify the final size as pixels? Also, what is loaction?
I though all you wanted was an example of using fx calculations. Sorry. See Anthony's outline above. You don't need percents. You just need to know how big to resize (in pixels or percent). If pixels is easier that is fine. -resize WidthxHeight
Then you just need to know where to place the upper left corner of the resized image into the background image.
convert backgroundimage \
\( image2 -crop W1xH1+X1+Y1 +repage -resize WW1xHH1 \) -geometry +x1+y1 -compose composemethod -composite \
\( image2 -crop W2xH2+X2+Y2 +repage -resize WW2xHH2 \) -geometry +x2+y2 -compose composemethod -composite \
...
resultimage
Where WW1xHH1 is the new size you want to make the subsection from the crop and x1 and y1 are the coordinates in the background image where you want the resized subsection's upper left corner to be placed
If you could post a link to an example image or images and explain what you want, then we could give you a better example.
Re: Copy and paste regions
Posted: 2010-10-13T03:37:03-07:00
by galv
Thank you both!!
Re: Copy and paste regions
Posted: 2010-10-13T14:42:24-07:00
by galv
Is there a way to copy instead of crop? Meaning I want to preserve the original image.
Re: Copy and paste regions
Posted: 2010-10-13T17:31:03-07:00
by fmw42
galv wrote:Is there a way to copy instead of crop? Meaning I want to preserve the original image.
Please clarify - what do you mean by copy in this context vs crop?
If you want the whole image and not a subsection, then just leave off the -crop ... +repage
If the second image is the same as the first, then replace image2 with -clone 0
see
http://www.imagemagick.org/Usage/basics/#clone
Re: Copy and paste regions
Posted: 2010-10-13T18:04:05-07:00
by galv
I mean that 'crop' is like 'cut' (think as in desktop file manager). It ruins the original image (it cuts pieces off). I would prefer 'copy' instead of 'cut', which would leave the original image intact.
Re: Copy and paste regions
Posted: 2010-10-13T18:12:51-07:00
by fmw42
galv wrote:I mean that 'crop' is like 'cut' (think as in desktop file manager). It ruins the original image (it cuts pieces off). I would prefer 'copy' instead of 'cut', which would leave the original image intact.
Sorry I still do not understand. If you want the whole image and not just a piece of it, then just leave off the -crop ... +repage.
Perhaps it would be helpful to list out the functional steps you want to do to process your image(s) and identify if you have just one input or more than one input. I am still not clear exactly what you are trying to do. I don't know if this a a new set of processing or your original one and still don't quite understand your original one.
Do you have any example from somewhere on the Internet that can explain what you are trying to accomplish?
Re: Copy and paste regions
Posted: 2010-10-13T18:18:51-07:00
by anthony
galv wrote:Is there a way to copy instead of crop? Meaning I want to preserve the original image.
That is the function of the 'clone' and the parenthesis. It makes a 'copy' of the image on-the-side whcih can then be cropped and repaged (remove virtual info about the crop). At the end of the parenthesis, you will then have two images in memory, the original and the cropped version.
I really suggest you read IM Examples, Image Sequences.
http://www.imagemagick.org/Usage/basics/#image_seq