Try this. Supply an image name on the command line and it will produce an image (junk.jpg) the same size as the original that looks roughly like this:

_____ |\___/| | | | | | | | | | |_| | |/___\|

where each of the 3 walls, the floor and ceilng are the original image "perspectivated" to fit.

You'll probably have to prefix the filename in the system command with your local favorite image viewer if your on *nix.

#! perl -slw use strict; use GD; my $img = GD::Image->new( $ARGV[ 0 ] ); my( $ox, $oy ) = $img->getBounds(); my $im2 = GD::Image->new( $ox, $oy, 1 ); $im2->copyResampled( $img, $ox/4, $oy/4, ## dstXY 0, 0, ## srcXY $ox/2, $oy/2, ## dstWH $ox, $oy ## srcWH ); my( $ys, $ye, $dy ) = ( 0, $oy, $oy/$ox ); for my $x ( 0 .. $ox/4 ) { $im2->copyResampled( $img, $x, $ys+=$dy, $x*4, 0, 1, $ye-=($dy*2), 4, $oy ); } ( $ys, $ye, $dy ) = ( $oy/4, $oy/2, $oy/$ox ); for my $x ( 0 .. $ox/4 ) { $im2->copyResampled( $img, $ox*3/4+$x, $ys-=$dy, $x*4, 0, 1, $ye+=$dy*2, 4, $oy ); } my( $xs, $xe, $dx ) = ( 0, $ox, $ox/$oy ); for my $y ( 0 .. $oy/4 ) { $im2->copyResampled( $img, $xs+=$dx, $y, 0, $y*4, $xe-=$dx*2, 1, $ox, 4, ); } ( $xs, $xe, $dx ) = ( $ox/4, $ox/2, $ox/$oy ); for my $y ( 0 .. $oy/4 ) { $im2->copyResampled( $img, $xs-=$dx, $oy*3/4+$y, 0, $y*4, $xe+=$dx*2, 1, $ox, 4, ); } open IMG, '>:raw', 'junk.jpg' or die $!; print IMG $im2->jpeg; close IMG; system 'junk.jpg';

Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.

In reply to Re: Module to skew an image by BrowserUk
in thread Module to skew an image by japhy

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.