Image_ratio_crop doesn't work

See all posts Reply

Image_ratio_crop doesn't work new!
by Fabio Spampinato, 12 years, 11 months ago
Hi,
first of all thank you for this wonderful class is really fantastic!
I use it on my under-development site: www.wallpaperup.com , everything works beautifully if the output image is resized while maintaining the same ratio, but does not work if the ratio of the output image is different. Test it yourself for better understanding, click on some resolutions under this wallpaper for example: http://www.wallpaperup.com/butterfly-224.html the code that deals with this is:

if ( ! file_exists ( $location . $width . $height . '.jpg' ) )  {
  include_once ( ROOTPATH . '/scripts/class.upload.php' );
  $handle = new Upload ( $original_file);
  if ( $handle->uploaded ) {
    $handle->image_resize = true;
    $handle->image_ratio_crop = true;
    $handle->image_x = $width;
    $handle->image_y = $height;
    $handle->file_new_name_body = $width . $height;
    $handle->process ( $location );
    if ( $handle->processed ) {
      unset ( $handle );
    }
  }
}

Which may be the problem? Thank you in advance.

( Where do I enter the code "echo $ handle-> log;" to write log file? And where it will be created? )Reply
Re: Image_ratio_crop doesn't work new!
by colin, 12 years, 11 months ago
I don't manage to get different resolutions of an image on your site. But I am not sure what doesn't work for you. What dimensions do you expect, and what do you get? Can you give me precise examples?

As for the log, you just add the line before you unset the $handle.Reply
Re: Image_ratio_crop doesn't work new!
by Fabio Spampinato, 12 years, 11 months ago
Thanks for answered my question.
I added "echo &handle->log;" before the unset instruction but where can i find the log file? I haven't found it.
By the way, the problem is:

the different resolutions of one wallpaper are generated by a link like this:

www.wallpaperup.com/wallpapers/download/224/1920/1080

"224" is the wallpaper's id, "1920" is the width of the new image and "1080" is the height. In this case the originale image size is 1920x1080 and if i try to create the image for these relsolutions: 1920x1080, 1366x768, 1280x720 or 852x480 everything works ok, i think because they don't require any crop because the ratio is the same. BUT if I try to create a 1280x800 version (or other) of the image, the class just returns a blank page in the browser, neither the image is created in the respective folder (all the resolutions of the original image are collected in a precise folder). It seems a weird problem, i have not found a solution.Reply
Re: Image_ratio_crop doesn't work new!
by colin, 12 years, 11 months ago
You may be running out of memory. Try to increase the available memory.

Do you see anything in the webserver logs?Reply
Re: Image_ratio_crop doesn't work new!
by Fabio Spampinato, 12 years, 11 months ago
I think I haven't logs, or at least I didn't found the file. I tried to resize a smaller image, only 200x136 and it worked all well, but still does not work if the image has a larger resolution, like 1600x1200. This is my php info: http://www.wallpaperup.com/phpinfo.php I think I have the memory limit setted to 90M, can the script asks for more? or maybe I have a different problem?Reply
Re: Image_ratio_crop doesn't work new!
by colin, 12 years, 11 months ago
You are most certainly running out of memory.

Search for memory in the site, or click here.

You can also check this post.Reply
Re: Image_ratio_crop doesn't work new!
by Fabio Spampinato, 12 years, 11 months ago
You're probably right ... I can't change the "memory_limit" parameter, maybe becouse I'm on a shared server, I asked it to my hosting company. A curiosity: I read in forums that doesn't matter the size in bytes of the image, but the number of its pixels, and if I understand it for each pixel we need a byte and then the image is processed, there is no a way to use less resources?Reply
Re: Image_ratio_crop doesn't work new!
by Fabio Spampinato, 12 years, 11 months ago
News: I increased the limit to 256M, but nothing has changedReply
Re: Image_ratio_crop doesn't work new!
by Fabio Spampinato, 12 years, 11 months ago
I FOUND THE PROBLEM! It's not a problem generated by this wonderful class but by an error when naming upload images. Thanks for your great support!Reply