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

avoid double compression while loading images #11

Closed
wants to merge 1 commit into from

Conversation

gentoomaniac
Copy link
Owner

@Shulyaka
The Idea is to create a thumbnail if none exists and caching is enabled.
Afterwards we try sending with readfile.
In case that fails or caching is disabled we encode on the fly via create_thumb and cached filename "null"

@Shulyaka
Copy link
Contributor

This way we are doubling the execution time if caching is enabled but failed. My approach is to have a single function that outputs thumbnail and writes to cache (if needed and able) simultaneously without any double work and without the need to write-then-read-again: https://github.com/Shulyaka/minigal-nano-ng/blob/master/src/createthumb.php

@gentoomaniac
Copy link
Owner Author

Ah now I get it :)
just one improvement then: replace "if($outfile)" with "if($caching)" as $outfile will be always set in the linked code (if I read it correctly)

We could also move the if statement then in create_thumb and let it do the magic to read from the cache
(In that case maybe rename it to get_resized_image or something like that)

@Shulyaka
Copy link
Contributor

Now I guess this one is also obsoleted by #13 .

@gentoomaniac
Copy link
Owner Author

jup. trashit

@gentoomaniac gentoomaniac deleted the doublecompression branch March 12, 2015 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants