jonasundderwolf / django-image-cropping

Django helper application to easily and non-destructively crop arbitrarily large images in admin and frontend.
Other
553 stars 131 forks source link

Template Tag Options are being Ignored #38

Closed Merenon closed 9 years ago

Merenon commented 10 years ago

I'm using the template tags to show and modify the different images, but none of the options (width, height, scale, max_size) seem to work:

{% load cropping %} < img src="{% cropped_thumbnail entry 'thumb_profile' width=200 %}" >

The physical image file with the correct size specs in the file name is being created, but the real image size is always the same.

I'm using: Django==1.6.1 easy-thumbnails==1.4 django-image-cropping==0.8

Any hints? Is this a bug?

escaped commented 10 years ago

Your cropped image may be too small. Try to using the 'upscale' parameter - otherwise no upscaling is performed.

Merenon commented 10 years ago

Thanks for your fast answer!

I'm experimenting with an 558 × 320 image, cropped to 247x247. Neither lower dimensions (width=100) nor higher dimensions (width=300 with upscale) seem to work with the template tag (see screenshot).

EDIT: It's working perfectly with the easy-thumbnails templatetag

screen shot 2014-01-20 at 15 45 45

jonasvp commented 10 years ago

I think I see where it's coming from: you've cropped the image too small, from (119,38) to (366,285). The cropped image therefore ends up being 247x247 in size. Not sure why easy-thumbnails won't scale it up again. The upscale operator might be parsed first, before image_cropping cuts it down to size.

You might want to enable the size warning to avoid croppings that are too small.

Merenon commented 10 years ago

Actually, size warning is enabled (IMAGE_CROPPING_SIZE_WARNING = True).

Never mind, if I'm the only one having this problems, I'm definitely okay with using easy-thumbnails template tag.

Still a pretty cool app :)

Thanks for your replies!

anrie commented 10 years ago

Just to be sure I understand the issue correctly: Things work like expected when you use the the easy thumbnails tag with the box parameter?

So the issue is limited to the cropped_thumbnail tag? And the problem is that the cropped image isn't upscaled to 300px in when using the cropped_thumbnail tag?

I'd say both options should yield the same results so if this isn't the case this is a bug. And if it's a bug I'd like to see a test that demonstrates the issue ;-)

Merenon commented 10 years ago

Japp, that's the case.

original image: 558 × 320 thumb_profile: cropped to 247x247

Neither {% cropped_thumbnail entry 'thumb_profile' width=200 %} nor {% cropped_thumbnail entry 'thumb_profile' width=300 upscale %} is working (correct file names, but wrong size of physical file) (screenshot 1) screen shot 2014-01-20 at 16 19 31

{% thumbnail entry.original_image 200x200 box=entry.thumb_profile crop upscale %} e.g. works just fine, as it should. (screenshot 2) screen shot 2014-01-20 at 16 19 24

It seems that the copped_thumbnail uses the "detail" option as default without being optional. That might crash the scaling action?

anrie commented 10 years ago

Alright, so it is an issue with the cropped_thumbnail tag. Not sure if it is the detail option though. But we'll look into it.

Merenon commented 10 years ago

Just looked into the code myself and changed the detail option to False... that solved the problem.

I'm trying to make the detail argument optional for the cropped_thumbail and opening a pull request.

Merenon commented 10 years ago

Pls see Pull Request: #39

anrie commented 10 years ago

Thanks for the PR. Now the tests have to be adjusted as well (https://travis-ci.org/jonasundderwolf/django-image-cropping/jobs/17283463).

Merenon commented 10 years ago

To be honest, I never worked with django unit tests (and travis) so far and I don't want to bother you with my experiments...

anrie commented 10 years ago

Okay, no problem. The next release will be about test coverage and cleanup anyway, so we'll just incorporate your fix when we're at it. Thanks for your contribution.

anrie commented 9 years ago

@Merenon Could you please check if everything is working as expected when you use the recent 0.9 release?

Merenon commented 9 years ago

My first experiments work perfectly... thanks a lot!