Something like this ought to do it.

Update: Fixed a couple of typos. And, having defined VERSION_33 in an arbitrary place in GD.xs and re-built GD, it now works.

#! perl -slw use strict; use GD; our $A ||= 45; my $imgIn = GD::Image->new( $ARGV[ 0 ] ) or die $!; my $cx = int $imgIn->width / 2; my $cy = int $imgIn->height /2; my $imgOut = GD::Image->new( $imgIn->getBounds, 1 ); $imgOut->copyRotated( $imgIn, $cx, $cy, 0, 0, $imgIn->getBounds, $A ); (my $ofile = $ARGV[0]) =~s[(\..*?$)][.r$A$1]; open OUT, '>:raw', $ofile or die $!; print OUT $imgOut->png; close OUT; system $ofile;

However, despite having installed the latest versions of GD(2.28) and libgd (2.0.33), running this dies with

libgd 2.0.33 or higher required for copyRotated support at ...

which is coming from gd.xs

void gdcopyRotated(dst,src,dstX,dstY,srcX,srcY,srcW,srcH,angle) GD::Image dst GD::Imagesrc double dstX double dstY int srcX int srcY int srcW int srcH int angle PROTOTYPE: $$$$$$$$$ CODE: { #ifdef VERSION_33 gdImageCopyRotated(dst,src,dstX,dstY,srcX,srcY,srcW,srcH,angle +); #else die("libgd 2.0.33 or higher required for copyRotated support") +; #endif }

but I can't work out where VERSION_33 should be defined?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

In reply to Re: Rotating an Image for an SDL::Surface by BrowserUk
in thread Rotating an Image for an SDL::Surface by hardburn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.