When I uploaded an image file, the thumbnail generation did create a smaller-sized image automatically (if I select the thumbnail option), the the generated image is not a shrinked version of the 'whole' image, but a cropped image (I mean, only grab 'portion' of the image which size id the given thumbnail size).

-Derek

Comments

huayen’s picture

I tested on the project demo page, same problem occurred for V6 demo, not occurred for V5 demo.

So, it is confirmed that this is a bug for IMCE V6.

ufku’s picture

Priority: Critical » Normal
Status: Active » Closed (works as designed)

IMCE uses Drupal's image_scale_and_crop() function to create thumbnails. It first scales the image and then crops it getting rid of excess parts.
You can change the issue category to feature request, requesting image_scale() function to be an optional or the default thumbnail generator.

ufku’s picture

Title: Thumbnail generation bug » Thumbnail generation options
Category: bug » feature
Status: Closed (works as designed) » Active

making this a feature request

drubeedoo’s picture

Hi ufku, thanks for adding this to your active list.

I've been searching for good image upload/resize functionality without the bloat of images as nodes, and IMCE is almost perfect, and would be so if aspect ratio was respected as an option in setup.

Thank you for all the work you've put into this great module! It is much appreciated.

Ignas’s picture

Status: Active » Needs review

insert this code in page.inc file function imce_resize_image above "//create file object"

  if (substr($op, 0, 5) == 'scale') {
    $aspect = $img['height'] / $img['width'];
    if ($aspect < $img['height'] / $width) {
        $width = (int)min($width, $img['width']);
        $height = (int)round($width * $aspect);
      }
      else {
        $height = (int)min($height, $img['height']);
        $width = (int)round($height / $aspect);
      }
  }

But this code forces all images scale proportionally - not square as in original IMCE.

andreiashu’s picture

If you want just to scale the image (not scale_and_crop it) then just search in page.inc file for "scale_and_crop" and replace it with "scale". Just that simple.
We should have an option to select the type of resizing for that particular resizing operation. Maybe a drop down box ?

yang_yi_cn’s picture

interested, subscribing

codemann’s picture

Very interesting, subscribing too.
I hope this will become a new feature to have the choice to scale or scale and crop.

ssm2017 Binder’s picture

subscribing

neek’s picture

or just crop like in imagecache..

nschloe’s picture

subscribing

ufku’s picture

Status: Needs review » Fixed

this was implemented on 6.x branch. wait for the next release.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

iantresman’s picture

Status: Closed (fixed) » Needs review

Can you just clarify what was implemented, and whether it made it into IMCE 6.x-1.2.

The ability to scale thumbnails? Preserve aspect ratio? Choosing between scaling, and, scaling and cropping?

iantresman’s picture

OK, just found where this is implemented in the current IMCE 6.x-1.2, on the IMCE Admin page, at the bottom, there is a section "Common settings" where you can choose between:

  • Scale the image with respect to the thumbnail dimensions.
  • First scale then crop the image to fit the thumbnail dimensions.

Unfortunately, it still doesn't preserve the image aspect ratio, which would be invaluable.

ufku’s picture

The first option does so.
What exactly do you expect it to do?
It scales the image[100x80] to [20x16](instead of [20x20]) for the thumb[20x20].
And an image[100x200] becomes [10x20] for the same thumb.

iantresman’s picture

Thanks for your reply. I don't think I was getting this effect. So I'll go and double check all my settings, and report back.

iantresman’s picture

Something is not quite right. Here's what I did, and the results:

  • I disable IMCE and uninstalled it.
  • Then I did a fresh install of IMCE 6.x-1.2, and re-enabled it in FCKEditor 6.x-1.3.
  • In IMCE I set the "Default method for creating thumbnails" as "Scale the image with respect to the thumbnail dimensions" because I did not want any cropping.
  • As User-1, I removed all Thumbnail definitions, and created just one with the name "Thumb" and dimensions: 196x256
  • In IMCE, I uploaded a new landscape image of size: 640 x 311
  • I selected this landscape image, selected Thumbnail, and checked my pre-defined thumnail size: Thumb (196x256)
  • IMCE reports a new thumbnail image of size: 195 x 95

However, the thumbnail created by IMCE looks distorted

  • Although IMCE says the new thumbnail is of size: 195 x 95, and displays it at this size, if I view the image directly, it is actually of size 196 x 196 (square)
  • And the image is cropped on the left and right hand sides

I had expected the image to be exactly 196 pixels wide (rather than 195), and 95 pixels wide, without any cropping.

On request, I'd be happy to give you access to my site, together with a set of instructions, so you can reproduce the behavior. Is contact via the Drupal contact form secure enough?

iantresman’s picture

Status: Needs review » Closed (fixed)

I just deleted the image on which I was creating the thumbnail, uploaded it again, and now everything works as expected.

Very bizarre. So please consider this resolved, and sorry for the hand-waiving.