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

Resize and crop by any single dimension #11

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mguryanov
Copy link

This changes serve to reduce image by any single dimension value. Hidden dimension is implicitly calculated as current image size.

@muxx
Copy link
Member

muxx commented Feb 21, 2018

Please fix in README alias /path/to/backgraund/image; to alias /path/to/background/image;

@muxx
Copy link
Member

muxx commented Feb 21, 2018

I think it will be more correctly if you show examples for existing location which were before in README because your location examples not give any specific info. Thanks.

@mguryanov
Copy link
Author

Ok, you're rigth. I will do it, but your location examples not correct.
This module can't handle multiple action like crop and resize.

this location chunk

       image_filter                resize $resize_width $resize_height;
       image_filter                crop   $crop_width $crop_height;

effect only last action - crop :)

@mguryanov
Copy link
Author

mguryanov commented Feb 26, 2018

In confirmation latest comment, we use nginx-image-filter about 2y+ in production. Multi-stage image modification can achieved by using proxy_pass wheel, for example

	##
	# CORRECT sequential image processing : ie crop after resize
	##

        location ~ ^/r/(?<resize_width>\d+|-)?x(?<resize_height>\d+|-)?/(?<img>[^/]+)$ {
		##
		# resize
		##
                image_filter resize $resize_width $resize_height;
                alias /path/to/image/$img;
        }

        location ~ ^/(?<resize>r/(?:\d+|-)?x(?:\d+|-)?)/c/(?<crop_width>\d+|-)?x(?<crop_height>\d+|-)?/(?<img>.+)$ {
		##
		# resize redirect
		##
                proxy_pass http://127.0.0.1/$resize/$img;

		##
		# crop
		##
                image_filter crop $crop_width $crop_height;
        }

unfortunately your configuration take handle only cropping, because there settings masquerade resizing

	##
	# INCORRECT sequential image processing : crop only, never resize
	##

        location ~ ^/intaro/r/(?<resize_width>\d+|-)x(?<resize_height>\d+|-)/c/(?<crop_width>\d+|-)x(?<crop_height>\d+|-)/(?<img>.+) {
                alias                       /Users/goshan/Sites/Zot/Zot/web/$img;

                try_files                   "" @404;

		#
		# Bad logic
		#
                image_filter                resize $resize_width $resize_height;
                image_filter                crop   $crop_width $crop_height;
	}

how to check it?
for example, we have image gdlogobig.png ( 336 x 218 )
according request - first step is resizing, and last is cropping, resizing checks by setting one dimension to lesser (50) when orignal value (336), and cropping values sets to originals (336 x 218)

http://localhost/intaro/r/50x218/c/336x218/gdlogobig.png 	<== INCORRECT, image not changed, because crop settings masquarade resizing
http://localhost/r/50x218/c/336x218/gdlogobig.png		<== CORRECT, image changed - resizing happened

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