mozahidrana / timthumb

Automatically exported from code.google.com/p/timthumb
0 stars 0 forks source link

New Feature : Flip (Horizontal, Vertical, Both) #322

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hello Everyone,

I just added a new feature to TimThumb: Flip (Horizontal, Vertical, Both) Option

Here is a new feature to be added:

/ / Code
    protected function imagecopyresampled(&$dst_image , $src_image , $dst_x , $dst_y , $src_x , $src_y , $dst_w , $dst_h , $src_w , $src_h){
        $flip = $this->param('fl', false);

        if ($flip && in_array($flip, array('v', 'h', 'b'))) {

            switch ( $flip )
            {

                case 'v': //vertical
                    $src_y                =    $src_h -1;
                    $src_h                =    -$src_h;
                break;

                case 'h': //horizontal
                    $src_x                =    $src_w -1;
                    $src_w                =    -$src_w;
                break;

                case 'b': //both
                    $src_x                =    $src_w -1;
                    $src_y                =    $src_h -1;
                    $src_w                =    -$src_w;
                    $src_h                =    -$src_h;
                break;

            }
        }

        imagecopyresampled ($dst_image , $src_image , $dst_x , $dst_y , $src_x , $src_y , $dst_w , $dst_h , $src_w , $src_h);

    }

// end code

And the two lines to modify: 
(line 652)

            imagecopyresampled ($canvas, $image, $origin_x, $origin_y, $src_x, $src_y, $new_width, $new_height, $src_w, $src_h);

        } else {

            // copy and resize part of an image with resampling
            imagecopyresampled ($canvas, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

        }

to :

            $this->imagecopyresampled ($canvas, $image, $origin_x, $origin_y, $src_x, $src_y, $new_width, $new_height, $src_w, $src_h);

        } else {

            // copy and resize part of an image with resampling
            $this->imagecopyresampled ($canvas, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

        }

Original issue reported on code.google.com by neopheus on 15 Jan 2012 at 3:20

Attachments:

GoogleCodeExporter commented 9 years ago
I hope this feature will be added soon timthumb
thank you in advance

Original comment by neopheus on 6 Feb 2012 at 7:41

GoogleCodeExporter commented 9 years ago
It is a useful feature. Hope it'll accepted.

Original comment by gianluig...@gmail.com on 12 Feb 2012 at 1:25

GoogleCodeExporter commented 9 years ago
yes
me too;)

Original comment by neopheus on 14 Feb 2012 at 9:13