Git Product home page Git Product logo

Comments (8)

roderik avatar roderik commented on June 8, 2024

I've run into the same issue, but with the caching part.

I've got a base image in png format
I've defined the format as jpg and when going through the controller, i get a file named png but it's a jpg with the correct mime type.
But this result file is saved to disk as .png and later calls just use the cached file so they return a jpg with png extension and filetype

As far as i can tell at the moment the browser "fixes" this, but it's bound to have an error somewhere...

from liipimaginebundle.

lsmith77 avatar lsmith77 commented on June 8, 2024

Can you elaborate a bit more?

Using this image:
https://github.com/liip/LiipHelloBundle/blob/query_param-proof-of-concept/Resources/public/images/image_test.jpg

And this template:
https://github.com/liip/LiipHelloBundle/blob/query_param-proof-of-concept/Resources/views/Hello/imagine.html.twig

I end up with:
http://screencast.com/t/zSnqMrldE

from liipimaginebundle.

roderik avatar roderik commented on June 8, 2024

I created a complete test case with a blank symfony: https://github.com/roderik/demoimagine

The test case contains your test image, once as PNG, once as JPG
I've created configs to create a 100x100 thumb for both these images, once with an output as jpg, once png
Configs are named so we can see what's what

Config: https://github.com/roderik/demoimagine/blob/master/app/config/config.yml

What i expect as cache files are:

jpgbase_pngresult: image_test.png
jpgbase_jpgresult: image_test.jpg
pngbase_pngresult: image_test.png
pngbase_jpgresult: image_test.jpg

What i actually get is

$ find web/uploads/cache -name image_test.* -exec file {} \;
web/uploads/cache/jpgbase_jpgresult/uploads/media/demoimages/image_test.jpg: JPEG image data, JFIF standard 1.01, comment: "CREATOR: gd-jpeg v1.0 (using IJ"
web/uploads/cache/jpgbase_pngresult/uploads/media/demoimages/image_test.jpg: PNG image data, 100 x 100, 8-bit/color RGBA, non-interlaced
web/uploads/cache/pngbase_jpgresult/uploads/media/demoimages/image_test.png: JPEG image data, JFIF standard 1.01, comment: "CREATOR: gd-jpeg v1.0 (using IJ"
web/uploads/cache/pngbase_pngresult/uploads/media/demoimages/image_test.png: PNG image data, 100 x 100, 8-bit/color RGBA, non-interlaced

The cache file is exactly the filename.ext as the base image
But the content of the file is the correct format.

So i have a image_test.png that is actually a jpg, and a image_test.jpg that is actually a png.

During the phase where the image is served through the controller, this is not a serious issue since the controller sets the correct content type. It only makes debugging harder.
During the phase where the url used in the html is the cached image, apache looks at the filename.ext and sends the wrong content type.

As far as we can tell at the moment, most browsers can handle this error, but its not really a good idea and has cost me a few hours debugging why my è§'('§ PNG was not becoming a JPG :)

from liipimaginebundle.

tigerman avatar tigerman commented on June 8, 2024

And yet, if you save the file (*.png with mime-type image/jpeg) to your harddisk, then some programs of my OS will not open it.

from liipimaginebundle.

lsmith77 avatar lsmith77 commented on June 8, 2024

can you check if #86 fixes the issue?

from liipimaginebundle.

roderik avatar roderik commented on June 8, 2024

Yes, this fixes it: https://github.com/roderik/demoimagine/commit/4095bb35045d4f018a7d6858ee008a04d0a8685b

I did have to edit Liip\ImagineBundle\DependencyInjection\LiipImagineExtension to the following to make it work in 2.0.15, there is only a Kernel::VERSION constant.

        //if ('2' == Kernel::MAJOR_VERSION && '0' == Kernel::MINOR_VERSION) {
            $container->removeDefinition('liip_imagine.cache.clearer');
        //}

thx!

from liipimaginebundle.

lsmith77 avatar lsmith77 commented on June 8, 2024

hmm are you sure about that issue with the kernel version? afaik it should work fine since 2.0.14

from liipimaginebundle.

roderik avatar roderik commented on June 8, 2024

ok, my bad, i accidently setup the test project with 2.0.10. Never mind me :)

from liipimaginebundle.

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.