titanium Posted May 16, 2013 Share Posted May 16, 2013 Hi, I wonder if there is an easy way to resize an image in the filesystem? Reason is: I need to display the same image in different sizes in some templates, but the image is already in the filesystem (in fact, it is deployed by another system). Since it should work automatically, I don't want to use the backend and create a field for it by hand. For example: instead of doing something like this (every picture has to be sized with Photoshop beforehand): <img src="/mypath/myimage.png" width="250" alt=""/> <img src="/mypath/myimage.png" width="500" alt=""/> it would be convenient to do something like this (does NOT work, just for illustrating what I would like to achieve): <?php $image = new PageImage('/var/www/mypath/myimage.png'); ?> <img src="<?php echo $image->size(250,0)->url; ?>" width="250" alt=""/> <img src="<?php echo $image->size(500,0)->url; ?>" width="500" alt=""/> In this manner the system would do the resizing, and Photoshop could rest in peace. I know phpThumb or timThumb can do this similar as well, but I would like to do it the Processwire way. Any hints welcome Link to comment Share on other sites More sharing options...
Wanze Posted May 16, 2013 Share Posted May 16, 2013 Well, the easiest solution would probably still be to assign an images field to your template(s) and import the image from the other system. Then and the images are stored in /site/assets/ - which is the Pw way If you can't do it this way, check out the ImageSizer class in /wire/core/. Link to comment Share on other sites More sharing options...
Roope Posted May 16, 2013 Share Posted May 16, 2013 Yeah, Soma was suggesting this also when I made similar question couple of days ago - haven't got time to test it yet though, but will do it tonight. http://processwire.com/talk/topic/3539-resizing-images-outside-pw-folders/#entry34751 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now