tb76 Posted September 25, 2019 Posted September 25, 2019 Hi! I want to create greyscaled versions of color images for a hover effect. In my template I am doing this: $is = new ImageSizer('/path/to/filename.ext'); $is->convertToGreyscale('/path/to/filename_new.ext'); (In my real code I am using filenames from page fields – the above code is just a shortened example.) Doing this, the original files always are overwritten. I checked the source code and found, that the optional parameter $dstFilename isn't passed through when calling convertToGreyscale. $dstFilename get's lost in /wire/core/ImageSizer.php: /** * Convert image to greyscale (black and white) * * @return bool * */ public function convertToGreyscale() { return $this->getEngine()->convertToGreyscale(); } I changed the method in /wire/core/ImageSizer.php to the follwoing code: public function convertToGreyscale($dstFilename = '') { return $this->getEngine()->convertToGreyscale($dstFilename); } Now, my template code works, but I changed a core file. I am wondering, if this is an issue with ImageSizer or if I am doing it wrong. Do I have to call convertToGreyscale in some other way?
dragan Posted September 25, 2019 Posted September 25, 2019 I'm not sure, but maybe it's meant to be used on a copy you create first (like you normally do in the GUI).
Robin S Posted September 25, 2019 Posted September 25, 2019 9 hours ago, tb76 said: I want to create greyscaled versions of color images for a hover effect. Your site visitors would have to download two copies of every image if you do this server-side. These days a CSS filter is the way to go: .bw-image:hover { filter:grayscale(100%); } And who cares about IE (or use a polyfill). But if you're sure you want to do this in PW and set a destination filename... $is = new ImageSizer('/path/to/filename.ext'); $is->getEngine()->convertToGreyscale('/path/to/filename_new.ext'); 1
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