rotating an image about bottom left corner

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
manit
Posts: 123
Joined: 2009-01-30T22:31:26-07:00

rotating an image about bottom left corner

Post by manit »

Hi , I am trying the following transformation
Image
https://ibb.co/qBTvW7S
h t t p s : / / i b b . c o / q B T v W 7 S
https://ibb.co/qBTvW7S
Here image is rotated by angle theta in anti-clockwise direction .
My image magick supports following

Code: Select all

$ convert -list distort
Affine
AffineProjection
ScaleRotateTranslate
SRT
Perspective
PerspectiveProjection
BilinearForward
BilinearReverse
Polynomial
Arc
Polar
DePolar
Barrel
BarrelInverse
Shepards
Resize
What should be my command ?

Thanks .
Last edited by manit on 2019-04-06T07:27:32-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: rotating an image about bottom right corner

Post by snibgo »

What version of IM? On what platform?

You say "rotating an image about bottom right corner" but your sketch shows rotation about the bottom-left corner. The sketch doesn't say where you want the boundaries of the output. This could be the (a) same dimensions as the input, or (b) just enough to show the complete input, or something else. What do you want in the virtual-pixel areas? I'll assume you want blue pixels. I'll show a rotation of -30 degrees.

The bottom-left coordinate is 0,%[fx:h-1].

(a) is:

Code: Select all

magick in.png -background Blue -virtual-pixel Background -distort SRT 0,%[fx:h-1],1,-30 out.png

(b) is the same but with "+distort", and you might (or might not) want "+repage":

Code: Select all

magick in.png -background Blue -virtual-pixel Background +distort SRT 0,%[fx:h-1],1,-30 +repage out.png
snibgo's IM pages: im.snibgo.com
manit
Posts: 123
Joined: 2009-01-30T22:31:26-07:00

Re: rotating an image about bottom right corner

Post by manit »

I am using
$ convert --version
Version: ImageMagick 6.8.9-9 Q16 x86_64 2018-09-28 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff wmf x xml zlib

on 64 bit ubuntu OS.

Sorry , I meant bottom left corner as picture shows.(corrected it in original post)
https://ibb.co/K0jKCFv shows that original image was shaded region of first quadrant and after rotation about bottom left corner I want image to look as it appears in that brown rectangle.
It means that after rotation , dimension of image increases .
Extra space should be filled by white pixel.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: rotating an image about bottom left corner

Post by snibgo »

Okay, so that is easy:

Code: Select all

convert in.png -rotate -30 out.png
Does that do what you want? If not, what is wrong with it?
snibgo's IM pages: im.snibgo.com
manit
Posts: 123
Joined: 2009-01-30T22:31:26-07:00

Re: rotating an image about bottom left corner

Post by manit »

Consider this
convert logo: -fill none -stroke black -strokewidth 3 -draw "rectangle 10,10 630,470" logo_rect.png
convert logo_rect.png -rotate -30 rotated-by-minus-30.png
This rotates image (by 30 degrees in anti clockwise direction) about its center not bottom left corner.

Thanks.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: rotating an image about bottom left corner

Post by fmw42 »

What is the difference between rotating about the bottom left corner or the center. The only difference would be the amount of image cropped off. Try

Code: Select all

convert in.png -background Blue -virtual-pixel Background -distort SRT 0,%[fx:h-1],1,-30 out.png
or

Code: Select all

convert in.png -background Blue -virtual-pixel Background +distort SRT 0,%[fx:h-1],1,-30 out.png
The latter is the same as rotating about the center

Code: Select all

convert in.png -background Blue -rotate -30 output.png
manit
Posts: 123
Joined: 2009-01-30T22:31:26-07:00

Re: rotating an image about bottom left corner

Post by manit »

yes , I think rotating the image with respect to bottom left corner gives result identical to that when image is rotated about its center.
This thread is solved.
Post Reply