Comments (5)
$img->source_path = 'path/to/original_image.ext';
// largest image
$img->target_path = 'path/to/large.ext';
$img->resize(1920, 0);
// medium, maybe
$img->target_path = 'path/to/medium.ext';
$img->resize(640, 0);
// thumbnail
$img->target_path = 'path/to/thumbnail.ext';
$img->resize(150, 75);
from zebra_image.
Thanks, when am using this kind, resize for medium or thumbnail does not crop properly.
For example:
$image = new Zebra_Image();
$img = '..path/image.png';
$thumb = '..path/thumb.png';
$image->source_path = $img;
list($width, $height) = getimagesize($img);
if($width > 800){
$awidth = "800";
} else {
$awidth = $width;
}
if($height > 2000){
$aheight = "2000";
} else {
$aheight = $height;
}
$image->target_path = $img;
$image->jpeg_quality = 60;
$image->preserve_aspect_ratio = true;
$image->enlarge_smaller_images = true;
$image->preserve_time = true;
if (!$image->resize($awidth, $aheight, ZEBRA_IMAGE_BOXED)) {
//error
} else {
echo 'Success!';
}
$image->target_path = $thumb;
if (!$image->resize(300, 600, ZEBRA_IMAGE_CROP_TOPLEFT)) {
//error
} else {
echo 'Success!';
}
Image which am uploading is 1200w * 4000h
first it puts in a box with 800w * 2000h
and for thumb it takes the whole image and creates thumbnail with 300w * 600h as its not cropping.
Is it may be am using preserve_aspect_ratio to true. hence this is the issue, right?
Or may be am trying to crop png/gif format other than jpg extension, is that could be the problem?
Hope you are understanding what am trying to say.
from zebra_image.
Yes, you have to unset the "preserve_aspect_ratio" for the second call, by setting it to false
from zebra_image.
No, even after the unset of "preserve_aspect_ratio", still the same.
May be am using "ZEBRA_IMAGE_BOXED" in the first call, for thumbnail also its applying the same. I dont understand.
Edit:
When I call for thumbnail only without second call, it works fine. But when I use twice, then it puts in the box with aspec ration, no matter i set aspect_ratio to false.
May be we have to unset "$method" in functoin resize then it might work i think.
from zebra_image.
I know it's been a year...
I've tested your code and seems to work as expected.
Indeed, the thumbnail is made from the first image - the one with 2000x4000. If you want to be made out of the already resized image you'd have set the source_path
to the newly created image first, before calling the second resize
from zebra_image.
Related Issues (20)
- PHP Warning exif_read_data(): File not supported HOT 1
- Manipulate stream instead of files HOT 1
- Gaussian Blur level
- Chrome
- PHP message: PHP Warning: exif_read_data(phpM6q1lm): Illegal IFD size in inc/ZebraImage.php on line 1360, referer: url HOT 2
- Supports SVG HOT 2
- Crop Images by Circle HOT 1
- Cropped image black borders HOT 11
- Release 2.3.0 is not in Packagist HOT 1
- Output Progressive / Interlaced JPG HOT 6
- WebP support? HOT 7
- Undefined variable $arguments... HOT 1
- Resize Mode Doesn't Work in PHP 8.1 HOT 12
- Animated WEBP images throw exception HOT 2
- php 8.1.12 - imagecolorsforindex Argument #2 ($color) is out of range HOT 3
- Supports ico and bmp formats? HOT 6
- No filter applied
- Composer package code mismatch even if version is the same as GitHub HOT 3
- resized png's do not retain alpha HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zebra_image.