GithubHelp home page GithubHelp logo

Comments (5)

stefangabos avatar stefangabos commented on June 16, 2024
$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.

pdctpa avatar pdctpa commented on June 16, 2024

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.

stefangabos avatar stefangabos commented on June 16, 2024

Yes, you have to unset the "preserve_aspect_ratio" for the second call, by setting it to false

from zebra_image.

pdctpa avatar pdctpa commented on June 16, 2024

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.

stefangabos avatar stefangabos commented on June 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.