Thumbnail tag broken for jpgs (not libjpg related) #268

Closed
pikeas opened this Issue Jun 10, 2012 · 21 comments

Comments

Projects
None yet
2 participants
@pikeas

pikeas commented Jun 10, 2012

In mezzanine.core.templatetags.mezzanine_tags, the thumbnail function saves its result with:

image = image.save(thumb_path, filetype, quality=quality, **image_info)

This works for PNGs. With a JPG, a size 0 output file is created. Removing the image_info argument seems to fix it, but I don't know enough about PIL to say why this is the case.

Here's the info dict for my test image:

{'jfif': 258, 'jfif_unit': 0, 'adobe': 100, 'progression': 1, 'progressive': 1, 'jfif_version': (1, 2), 'adobe_transform': 100, 'jfif_density': (100, 100)}

@stephenmcd

This comment has been minimized.

Show comment Hide comment
@stephenmcd

stephenmcd Jun 10, 2012

Owner

Can you test the image on the demo site? That'll kill two birds with one stone. If it works, then we've ruled out it being Mezzanine specific. If it doesn't work, you can link to the original uploaded image (in this thread) and I can get the image and debug it locally

Owner

stephenmcd commented Jun 10, 2012

Can you test the image on the demo site? That'll kill two birds with one stone. If it works, then we've ruled out it being Mezzanine specific. If it doesn't work, you can link to the original uploaded image (in this thread) and I can get the image and debug it locally

@pikeas

This comment has been minimized.

Show comment Hide comment
@pikeas

pikeas Jun 11, 2012

Works on the demo site in a gallery. Blog post pages don't have an image field to go with them.

Here's the image: http://pawky.net/test.jpg Try reproducing locally, either by uploading the image or in Python by importing the function and calling it manually.

Interestingly, the 60x60 thumbnail for the same image (auto-generated by filebrowser?) was created without issue.

El Jun 10, 2012, a las 11:05 PM, Stephen McDonald escribió:

Can you test the image on the demo site? That'll kill two birds with one stone. If it works, then we've ruled out it being Mezzanine specific. If it doesn't work, you can link to the original uploaded image (in this thread) and I can get the image and debug it locally


Reply to this email directly or view it on GitHub:
#268 (comment)

pikeas commented Jun 11, 2012

Works on the demo site in a gallery. Blog post pages don't have an image field to go with them.

Here's the image: http://pawky.net/test.jpg Try reproducing locally, either by uploading the image or in Python by importing the function and calling it manually.

Interestingly, the 60x60 thumbnail for the same image (auto-generated by filebrowser?) was created without issue.

El Jun 10, 2012, a las 11:05 PM, Stephen McDonald escribió:

Can you test the image on the demo site? That'll kill two birds with one stone. If it works, then we've ruled out it being Mezzanine specific. If it doesn't work, you can link to the original uploaded image (in this thread) and I can get the image and debug it locally


Reply to this email directly or view it on GitHub:
#268 (comment)

@stephenmcd

This comment has been minimized.

Show comment Hide comment
@stephenmcd

stephenmcd Jun 11, 2012

Owner

Works fine for me, both as a filebrowser field and a regular Django file field - thumbnailing works in both cases.

Owner

stephenmcd commented Jun 11, 2012

Works fine for me, both as a filebrowser field and a regular Django file field - thumbnailing works in both cases.

@pikeas

This comment has been minimized.

Show comment Hide comment
@pikeas

pikeas Jun 11, 2012

Just tested locally to the same result. Might be something unique to EC2/Ubuntu?

El Jun 11, 2012, a las 12:36 PM, Stephen McDonald escribió:

Works fine for me, both as a filebrowser field and a regular Django file field - thumbnailing works in both cases.


Reply to this email directly or view it on GitHub:
#268 (comment)

pikeas commented Jun 11, 2012

Just tested locally to the same result. Might be something unique to EC2/Ubuntu?

El Jun 11, 2012, a las 12:36 PM, Stephen McDonald escribió:

Works fine for me, both as a filebrowser field and a regular Django file field - thumbnailing works in both cases.


Reply to this email directly or view it on GitHub:
#268 (comment)

@stephenmcd

This comment has been minimized.

Show comment Hide comment
@stephenmcd

stephenmcd Jun 11, 2012

Owner

Not sure. Demo site's running on ubuntu 12.04

On Mon, Jun 11, 2012 at 8:43 PM, pikeas <
reply@reply.github.com

wrote:

Just tested locally to the same result. Might be something unique to
EC2/Ubuntu?

El Jun 11, 2012, a las 12:36 PM, Stephen McDonald escribió:

Works fine for me, both as a filebrowser field and a regular Django file
field - thumbnailing works in both cases.


Reply to this email directly or view it on GitHub:
#268 (comment)


Reply to this email directly or view it on GitHub:
#268 (comment)

Stephen McDonald
http://jupo.org

Owner

stephenmcd commented Jun 11, 2012

Not sure. Demo site's running on ubuntu 12.04

On Mon, Jun 11, 2012 at 8:43 PM, pikeas <
reply@reply.github.com

wrote:

Just tested locally to the same result. Might be something unique to
EC2/Ubuntu?

El Jun 11, 2012, a las 12:36 PM, Stephen McDonald escribió:

Works fine for me, both as a filebrowser field and a regular Django file
field - thumbnailing works in both cases.


Reply to this email directly or view it on GitHub:
#268 (comment)


Reply to this email directly or view it on GitHub:
#268 (comment)

Stephen McDonald
http://jupo.org

@pikeas

This comment has been minimized.

Show comment Hide comment
@pikeas

pikeas Jun 11, 2012

What additional information can I provide to help determine why it's broken?

El Jun 11, 2012, a las 12:45 PM, Stephen McDonald escribió:

Not sure. Demo site's running on ubuntu 12.04

On Mon, Jun 11, 2012 at 8:43 PM, pikeas <
reply@reply.github.com

wrote:

Just tested locally to the same result. Might be something unique to
EC2/Ubuntu?

El Jun 11, 2012, a las 12:36 PM, Stephen McDonald escribió:

Works fine for me, both as a filebrowser field and a regular Django file
field - thumbnailing works in both cases.


Reply to this email directly or view it on GitHub:
#268 (comment)


Reply to this email directly or view it on GitHub:
#268 (comment)

Stephen McDonald
http://jupo.org


Reply to this email directly or view it on GitHub:
#268 (comment)

pikeas commented Jun 11, 2012

What additional information can I provide to help determine why it's broken?

El Jun 11, 2012, a las 12:45 PM, Stephen McDonald escribió:

Not sure. Demo site's running on ubuntu 12.04

On Mon, Jun 11, 2012 at 8:43 PM, pikeas <
reply@reply.github.com

wrote:

Just tested locally to the same result. Might be something unique to
EC2/Ubuntu?

El Jun 11, 2012, a las 12:36 PM, Stephen McDonald escribió:

Works fine for me, both as a filebrowser field and a regular Django file
field - thumbnailing works in both cases.


Reply to this email directly or view it on GitHub:
#268 (comment)


Reply to this email directly or view it on GitHub:
#268 (comment)

Stephen McDonald
http://jupo.org


Reply to this email directly or view it on GitHub:
#268 (comment)

@stephenmcd

This comment has been minimized.

Show comment Hide comment
@stephenmcd

stephenmcd Jun 11, 2012

Owner

Well I can't replicate it on two different environments. It seems like it's
related to your PIL installed so it's not specifically a Mezzanine issue. I
don't know enough about PIL to suggest anything else unfortunately.

On Mon, Jun 11, 2012 at 8:50 PM, pikeas <
reply@reply.github.com

wrote:

What additional information can I provide to help determine why it's
broken?

El Jun 11, 2012, a las 12:45 PM, Stephen McDonald escribió:

Not sure. Demo site's running on ubuntu 12.04

On Mon, Jun 11, 2012 at 8:43 PM, pikeas <
reply@reply.github.com

wrote:

Just tested locally to the same result. Might be something unique to
EC2/Ubuntu?

El Jun 11, 2012, a las 12:36 PM, Stephen McDonald escribió:

Works fine for me, both as a filebrowser field and a regular Django
file
field - thumbnailing works in both cases.


Reply to this email directly or view it on GitHub:

#268 (comment)


Reply to this email directly or view it on GitHub:
#268 (comment)

Stephen McDonald
http://jupo.org


Reply to this email directly or view it on GitHub:
#268 (comment)


Reply to this email directly or view it on GitHub:
#268 (comment)

Stephen McDonald
http://jupo.org

Owner

stephenmcd commented Jun 11, 2012

Well I can't replicate it on two different environments. It seems like it's
related to your PIL installed so it's not specifically a Mezzanine issue. I
don't know enough about PIL to suggest anything else unfortunately.

On Mon, Jun 11, 2012 at 8:50 PM, pikeas <
reply@reply.github.com

wrote:

What additional information can I provide to help determine why it's
broken?

El Jun 11, 2012, a las 12:45 PM, Stephen McDonald escribió:

Not sure. Demo site's running on ubuntu 12.04

On Mon, Jun 11, 2012 at 8:43 PM, pikeas <
reply@reply.github.com

wrote:

Just tested locally to the same result. Might be something unique to
EC2/Ubuntu?

El Jun 11, 2012, a las 12:36 PM, Stephen McDonald escribió:

Works fine for me, both as a filebrowser field and a regular Django
file
field - thumbnailing works in both cases.


Reply to this email directly or view it on GitHub:

#268 (comment)


Reply to this email directly or view it on GitHub:
#268 (comment)

Stephen McDonald
http://jupo.org


Reply to this email directly or view it on GitHub:
#268 (comment)


Reply to this email directly or view it on GitHub:
#268 (comment)

Stephen McDonald
http://jupo.org

@pikeas

This comment has been minimized.

Show comment Hide comment
@pikeas

pikeas Jun 14, 2012

What version of Pillow are you using?

pikeas commented Jun 14, 2012

What version of Pillow are you using?

@stephenmcd stephenmcd closed this Jul 2, 2012

@pikeas

This comment has been minimized.

Show comment Hide comment
@pikeas

pikeas Jul 2, 2012

I'm still awaiting a reply from PIL regarding this issue, but I can confirm that it also occurs in my dev environment - OS X 10.7.4 with python 2.7.1 and Pillow 1.7.7.

pikeas commented Jul 2, 2012

I'm still awaiting a reply from PIL regarding this issue, but I can confirm that it also occurs in my dev environment - OS X 10.7.4 with python 2.7.1 and Pillow 1.7.7.

@stephenmcd stephenmcd reopened this Jul 2, 2012

@stephenmcd

This comment has been minimized.

Show comment Hide comment
@stephenmcd

stephenmcd Jul 2, 2012

Owner

Sorry I thought the last comment was from a different user and that you hadn't replied to that. Will have a look at my pillow version tonight when I get home.

Owner

stephenmcd commented Jul 2, 2012

Sorry I thought the last comment was from a different user and that you hadn't replied to that. Will have a look at my pillow version tonight when I get home.

@stephenmcd

This comment has been minimized.

Show comment Hide comment
@stephenmcd

This comment has been minimized.

Show comment Hide comment
@stephenmcd

stephenmcd Jul 2, 2012

Owner

Also here - http://www.p16blog.com/p16/2008/05/appengine-installing-pil-on-os-x-1053.html

I'm actually going to close this issue again sorry - I'm fairly certain it's a PIL/Pillow issue, not Mezzanine itself.

Owner

stephenmcd commented Jul 2, 2012

Also here - http://www.p16blog.com/p16/2008/05/appengine-installing-pil-on-os-x-1053.html

I'm actually going to close this issue again sorry - I'm fairly certain it's a PIL/Pillow issue, not Mezzanine itself.

@stephenmcd stephenmcd closed this Jul 2, 2012

@pikeas

This comment has been minimized.

Show comment Hide comment
@pikeas

pikeas Jul 2, 2012

Thanks Stephen. But per my original post, all my libraries work correctly, and I am experiencing this issue under both OS X and AWS Ubuntu. I'm using stock Pillow in both cases, and my AWS deployment is largely Mezzanine's fabfile.

I'll continue trying to get a reply from PIL, and will post again here if and when I receive it.

pikeas commented Jul 2, 2012

Thanks Stephen. But per my original post, all my libraries work correctly, and I am experiencing this issue under both OS X and AWS Ubuntu. I'm using stock Pillow in both cases, and my AWS deployment is largely Mezzanine's fabfile.

I'll continue trying to get a reply from PIL, and will post again here if and when I receive it.

@stephenmcd stephenmcd reopened this Jul 2, 2012

@stephenmcd

This comment has been minimized.

Show comment Hide comment
@stephenmcd

stephenmcd Jul 2, 2012

Owner

Sorry I'm being really hasty due to lack of time - I really shouldn't do that.

Just re-read the original issue and it's clear we can get this working in Mezzanine - I'd just like to be able to reproduce it first, which I wasn't able to do with the image you showed me.

Owner

stephenmcd commented Jul 2, 2012

Sorry I'm being really hasty due to lack of time - I really shouldn't do that.

Just re-read the original issue and it's clear we can get this working in Mezzanine - I'd just like to be able to reproduce it first, which I wasn't able to do with the image you showed me.

@stephenmcd

This comment has been minimized.

Show comment Hide comment
@stephenmcd

stephenmcd Jul 3, 2012

Owner

I've got Pillow 1.7.5 on OSX and 1.7.7 on Linux

Owner

stephenmcd commented Jul 3, 2012

I've got Pillow 1.7.5 on OSX and 1.7.7 on Linux

@stephenmcd

This comment has been minimized.

Show comment Hide comment
@stephenmcd

stephenmcd Jul 3, 2012

Owner

The Linux server is the one hosting the demo site, which I was just able to successfully resize the test image on:

http://mezzanine.jupo.org/static/media/uploads/.thumbnails/test-60x60.jpg

It's worth noting that the setup of this server is entirely automated, using the fabfile here:

https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/project_template/fabfile.py#L268

That link points to the line where the non-python dependencies are first installed, such as libjpeg-dev which is for pillow to work correctly.

Owner

stephenmcd commented Jul 3, 2012

The Linux server is the one hosting the demo site, which I was just able to successfully resize the test image on:

http://mezzanine.jupo.org/static/media/uploads/.thumbnails/test-60x60.jpg

It's worth noting that the setup of this server is entirely automated, using the fabfile here:

https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/project_template/fabfile.py#L268

That link points to the line where the non-python dependencies are first installed, such as libjpeg-dev which is for pillow to work correctly.

@stephenmcd

This comment has been minimized.

Show comment Hide comment
@stephenmcd

stephenmcd Jul 3, 2012

Owner

Good news - I've been able to replicate this. I wasn't noticing it with the image you gave, since when the resize fails the first time and creates the empty image, it ends up returning the original image URL, so it appears to have worked. On a reload of the page after that, the (empty) image exists, so its path is returned, which is broken.

Owner

stephenmcd commented Jul 3, 2012

Good news - I've been able to replicate this. I wasn't noticing it with the image you gave, since when the resize fails the first time and creates the empty image, it ends up returning the original image URL, so it appears to have worked. On a reload of the page after that, the (empty) image exists, so its path is returned, which is broken.

@pikeas

This comment has been minimized.

Show comment Hide comment
@pikeas

pikeas Jul 3, 2012

Great, I'm glad you're able to reproduce it! Do you have any contact with PIL's developers? I've pinged #python about this a few times, and posted on the PIL mailing list, all with no luck.

pikeas commented Jul 3, 2012

Great, I'm glad you're able to reproduce it! Do you have any contact with PIL's developers? I've pinged #python about this a few times, and posted on the PIL mailing list, all with no luck.

@stephenmcd

This comment has been minimized.

Show comment Hide comment
@stephenmcd

stephenmcd Jul 3, 2012

Owner

No I don't - but at the very least, you've identified an error condition we
can trap (thumbnail is 0 bytes) and a workaround (remove the image info),
so we can trap that and try again without image info.

Hopefully I can work out a better solution than that.

On Wed, Jul 4, 2012 at 6:32 AM, pikeas <
reply@reply.github.com

wrote:

Great, I'm glad you're able to reproduce it! Do you have any contact with
PIL's developers? I've pinged #python about this a few times, and posted on
the PIL mailing list, all with no luck.


Reply to this email directly or view it on GitHub:
#268 (comment)

Stephen McDonald
http://jupo.org

Owner

stephenmcd commented Jul 3, 2012

No I don't - but at the very least, you've identified an error condition we
can trap (thumbnail is 0 bytes) and a workaround (remove the image info),
so we can trap that and try again without image info.

Hopefully I can work out a better solution than that.

On Wed, Jul 4, 2012 at 6:32 AM, pikeas <
reply@reply.github.com

wrote:

Great, I'm glad you're able to reproduce it! Do you have any contact with
PIL's developers? I've pinged #python about this a few times, and posted on
the PIL mailing list, all with no luck.


Reply to this email directly or view it on GitHub:
#268 (comment)

Stephen McDonald
http://jupo.org

@stephenmcd

This comment has been minimized.

Show comment Hide comment
@stephenmcd

stephenmcd Jul 3, 2012

Owner

Now I can trap the error and see the exception: "encoder error -2 when writing image file"

Turns out it's a progressive jpg, and the solution is here: http://stackoverflow.com/questions/6788398/how-to-save-progressive-jpeg-using-python-pil-1-1-7

Owner

stephenmcd commented Jul 3, 2012

Now I can trap the error and see the exception: "encoder error -2 when writing image file"

Turns out it's a progressive jpg, and the solution is here: http://stackoverflow.com/questions/6788398/how-to-save-progressive-jpeg-using-python-pil-1-1-7

@stephenmcd stephenmcd closed this in bba697d Jul 3, 2012

@stephenmcd

This comment has been minimized.

Show comment Hide comment
@stephenmcd

stephenmcd Jul 3, 2012

Owner

Should be fixed now. Sorry for taking so long to get it sorted out. It wasn't until I had clear steps to reproduce it (in #295) that I could see the issue.

Owner

stephenmcd commented Jul 3, 2012

Should be fixed now. Sorry for taking so long to get it sorted out. It wasn't until I had clear steps to reproduce it (in #295) that I could see the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment