Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: is there possibility to retrieve source image without processing it? #1152

Open
jkabat opened this issue Jan 7, 2019 · 7 comments
Labels
Level: New Feature 🆕 This item involves the introduction of new functionality.

Comments

@jkabat
Copy link
Contributor

jkabat commented Jan 7, 2019

I tried to search for answer but failed to find one.

Sometimes you need to grab source image without touching it and if I use |imagine_filter in twig, I always end up by getting processed file, even if you do not set any filter at all.

Is there some option I'm missing (quality = 100%, or similar)? Or the only way is to create custom filter which will basically copy the source to target?

@robfrawley
Copy link
Collaborator

robfrawley commented Jan 7, 2019

It will always cache a new copy of the file (using the original file as its source), but it will not apply any transformations or post-processors to the file, assuming you have defined an empty filter-set and post-processor configuration entry.

In this situation, while it is a new file, the only operations that are performed with an empty filter-set/post-processor configuration are:

  1. There is a check for a matching cache file, which is returned if one is found that is not stale; otherwise, if no cache file exists or if the existing cache file is stale, the process continues at the next step.
  2. The image data is read into a concrete ImageInterface instance using the imagine-library API (which internally uses the configured image manipulation library; one of gd, imagick, or gmagick).
  3. The image data from the prior created ImageInterface instance is written out to a cache file.
  4. The saved cache file is then served as the image resource for all matching requests.

Nothing else is performed. Have you checked your full configuration by dumping the bundle's config using the Symfony console to ensure there are no other options that could be effecting output?

The architecture of this bundle currently requires an intermediate cache file, so I do not believe you can completely remove this functionality, as you requested to do in your question.

If the cache file is substantially different from the original input file, there must be something occuring within the external imagine-library; as far as I understand, this bundle does not introduce any changes in this situation. I would look into how that external library behaves and any options it may apply itself.

@dmagician
Copy link

As I understand it. Steps 2 and 3 always manipulate the original file data through Imagine (open, save), because Imagine always opens the resource (using gd, imagick or gmagick) and saves it to desired path (which always changes the file data).

Would it be possible to add filter parameter to LiipImagineBundle (for example passthrough: true) that would skip the steps 2 and 3. and instead just copy the original file to cache?

@jkabat
Copy link
Contributor Author

jkabat commented Jan 8, 2019

@robfrawley thanks for your comprehensive answer. So there might be some defaults which are used by imagine library and which are causing degradation (or manipulation) of the output.

What would you suggest if I'd like in certain cases (let's say for filter_set named "original") skip opening source by configured driver. I do not know architecture of the bundle that's why I'm asking - would be possible to eg: change configured driver to custom "dummy" one dynamically?

The point is to use cache for these "original" files the same way as it is done for all other filter_sets.

@guillermogfer
Copy link

guillermogfer commented Nov 26, 2020

I am also experiencing related issues by filtering gif images. The output cache resolved image increases the original size even without performing any filter or post-processor operations.

Because we have images with different mime types, we wanted to apply certain filter_sets to the images skipping the gif ones. We tried with empty filter_sets and runtime options, also with quality of 100, but something occurs while saving the new image binary that increases significantly the size.

Is there any workaround to achieve this?
One solution could be to check the image mime type and only apply the filter_set if matches desired extensions by it seems a bit ugly way.

@dbu
Copy link
Member

dbu commented Oct 6, 2021

i am cleaning up old issues. if this is still relevant and keeps happening with the latest version of the bundle, please reopen the issue.

@dbu dbu closed this as completed Oct 6, 2021
@jkabat
Copy link
Contributor Author

jkabat commented Oct 19, 2021

@dbu I do not have access to reopen, but Im still interesting in solution if anybody will take a shot on this one.

@dbu dbu reopened this Oct 19, 2021
@dbu
Copy link
Member

dbu commented Oct 19, 2021

i reopened the issue. can you propose a solution @jkabat how this should be handled?

@dbu dbu added the Level: New Feature 🆕 This item involves the introduction of new functionality. label Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Level: New Feature 🆕 This item involves the introduction of new functionality.
Projects
None yet
Development

No branches or pull requests

5 participants