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

prevent artefacts in white areas #195

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion adaptive-images.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ function generateImage($source_file, $cache_file, $resolution) {
imagefilledrectangle($dst, 0, 0, $new_width, $new_height, $transparent);
}

// invert the image to prevent atrifacts on white areas
imagefilter($src, IMG_FILTER_NEGATE);
ImageCopyResampled($dst, $src, 0, 0, 0, 0, $new_width, $new_height, $width, $height); // do the resize in memory
imagefilter($dst, IMG_FILTER_NEGATE);
ImageDestroy($src);

// sharpen the image?
Expand Down Expand Up @@ -319,4 +322,4 @@ function generateImage($source_file, $cache_file, $resolution) {

/* It exists as a source file, and it doesn't exist cached - lets make one: */
$file = generateImage($source_file, $cache_file, $resolution);
sendImage($file, $browser_cache);
sendImage($file, $browser_cache);