Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $image = new JImage('/path/to/original.jpg');
- $height = $image->getHeight();
- $width = $image->getWidth();
- if ($height > $width) {
- $crop_square = $width;
- $crop_top = ($height - $width) / 2;
- $crop_left = 0;
- } else {
- $crop_square = $height;
- $crop_top = 0;
- $crop_left = ($width - $height) / 2;
- }
- $image = $image->crop($crop_square, $crop_square, $crop_left, $crop_top, false);
- $small = $image->resize(48, 48);
- $large = $image->resize(160, 160);
- $small->toFile('/path/to/small.jpg');
- $large->toFile('/path/to/large.jpg');
Add Comment
Please, Sign In to add comment