Direction of flop() (or flip())

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
kirash4
Posts: 34
Joined: 2010-04-12T15:30:59-07:00
Authentication code: 8675308

Direction of flop() (or flip())

Post by kirash4 »

Following this snippet of code:

Code: Select all

  try {
    list<Image> imagesList;
    Image srcImage(imgFilename);
    Image cloneImg = srcImage;
    imagesList.push_back(srcImage);
    cloneImg.flop();
    imagesList.push_back(cloneImg);

    Montage montageSettings;
    montageSettings.geometry(Geometry(srcImage.columns(), srcImage.rows()));
    montageSettings.tile("2x1");

    list<Image> montageList;
    montageImages(&montageList, imagesList.begin(), imagesList.end(), montageSettings);
    writeImages(montageList.begin(), montageList.end(), flopFilename);
  }
The resulting image is a flop in what I would refer to as a left to right direction (it's flopped along the right edge.) How would I go about making it a right to left direction (flopped along the left edge)? The same for flip(), the resulting image is an upwards flip (along the upper edge). How do I make it a downwards flip (along the bottom edge)? I'd like to make it so the user, when invoking the command, will indicate which direction they want the flip or flop (up/down/left/right).
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Direction of flop() (or flip())

Post by fmw42 »

What is the difference between a horizontal mirror between left to right or right to left? No difference as far as I understand. Please clarify.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Direction of flop() (or flip())

Post by Bonzo »

I think the OP wants to do something like this very rough sketch:
Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Direction of flop() (or flip())

Post by fmw42 »

I don't understand your diagram, Bonzo. But perhaps they want to mirror and then append.

Code: Select all

convert image \( -clone 0 -flop \) +append result
or the other way

Code: Select all

convert image \( -clone 0 -flop \) +swap +append result
But I do not know the equivalent in any of the APIs.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Direction of flop() (or flip())

Post by Bonzo »

My sketch was to try and show the options the OP wanted but looking at it I can now see that you are correct.

The mirror along the top is the same result as the mirror along the bottom and the mirror along the edges are the same. Before I looked at my own sketch again I thought they would be different!!
kirash4
Posts: 34
Joined: 2010-04-12T15:30:59-07:00
Authentication code: 8675308

Re: Direction of flop() (or flip())

Post by kirash4 »

The resulting mirror image is the same whether it's a flip or a flop. It's along which edge is what makes the difference in the resulting image:
Image

The code as written performs what I expect it to do. I'm trying to figure out how to go the other direction. Same thing with flip. Both of them seem to have their preferred edge to flop or flip on, so I'm wondering if there's a way to change that edge.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Direction of flop() (or flip())

Post by fmw42 »

As in the code I provide, the way to handle that is to swap the order of the image before appending. I used +swap. I am not sure what the equivalent is in your API, since I only use the command line. But you can change the order of the two images to be appended in any way you can and it should work as you want.

Montage is probably overkill. Look for appendImage or something like that and swapImage or something like that or just change the code to reverse the order of the image in the append or montage statement.
kirash4
Posts: 34
Joined: 2010-04-12T15:30:59-07:00
Authentication code: 8675308

Re: Direction of flop() (or flip())

Post by kirash4 »

I tried changing the order in the montage command, it never worked. Got into a weird loop that just ate up memory and never wrote anything out. I'll see what the swap equivalent is, if there is one for the Magick++ API.

Montage should respect the images, but you may have to do something different about which is the main image.

However, if you change to append rather than montage, it might work. I really don't know how the APIs work with regard to using different order of files. Perhaps it is not so simple. But there should be a way. Nevertheless, if there is a swap, that should work.

Someone who knows your API should be able to help with it. Sorry I cannot help further in that regard.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Direction of flop() (or flip())

Post by dlemstra »

Shouldn't you just change imagesList.push_back(cloneImg); to imagesList.push_front(cloneImg); ? This will put the images in a different order.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
kirash4
Posts: 34
Joined: 2010-04-12T15:30:59-07:00
Authentication code: 8675308

Re: Direction of flop() (or flip())

Post by kirash4 »

dlemstra wrote:Shouldn't you just change imagesList.push_back(cloneImg); to imagesList.push_front(cloneImg); ? This will put the images in a different order.
You'd think, but no. The resulting image is the same.

And changing which gets pushed back first also results in the same thing.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Direction of flop() (or flip())

Post by dlemstra »

Have you tried using 'appendImages' instead of montage? This should be enough for you. You still need to put the 'cloned flop' at the beginning of your list.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
kirash4
Posts: 34
Joined: 2010-04-12T15:30:59-07:00
Authentication code: 8675308

Re: Direction of flop() (or flip())

Post by kirash4 »

Ok, SHOOT ME NOW ... just aim right for the center of my forehead and shoot ... urgh. imagesList.push_front() works as you suggested it should. Except, the file I was editing is not the file that was getting compiled. I was editing -v01 while the IDE was compiling -v02. I just noticed my second computer telling me that -v01 has changed and I went, huh, shouldn't .. then it hit me. I think it's time for me to quit now and go watch a movie or something ... sheesh.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Direction of flop() (or flip())

Post by dlemstra »

I have absolutely never made such a mistake :)
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Post Reply