Problems in resizing images

Hello,
I use the followig code in my template and don’t get the resize() running:

if ($page->cover()->isNotEmpty()):
	$thumb 	= $page->cover()->toFile();

	$thumb 	= $thumb->grayscale();
	$thumb 	= $thumb->resize(500);
	$thumb 	= $thumb->blur(30);

	echo $thumb->url();
endif;

Grayscale is working, resize and blur not. Imagemagic is activated on server. Any ideas what could help to solve it?

Thanks in advance.
Chris

A new file called blabla-500x-blur30-bw.jpg is generated when I use the code below. but the image is still the original. not resized, no blur, no grayscale :frowning:

$thumb = $thumb->thumb([
	'width' => '500',
	'grayscale' => true,
	'crop' => false,
	'blur' => 30
])->url();

Do I have to set additional permissions on server which I don’t know about?

I found a solution. bin pathin config php was wrong.
Removing this line does the job :slight_smile:

<?php

return [
    'thumbs' => [
	'driver'    => 'im',
	'quality'   => 90,
//	'bin'       => '/usr/local/bin/convert',
	'interlace' => true
	]
];
1 Like

Your if statement is basically useless, should be

if ($page->cover()->toFile()):
	// rest of code
endif;

Background: If the field is not empty but the file doesn’t exist despite the field still having a value, your code will fail. On the other hand, if the field is empty, the toFile() method will return null, so you don’t need two if-clauses.
The reason why your original code did not work is because you cannot modify a thumb again but have to do all changes in one using the thumb() method like you finally did.

Thank you, I will update the like xyou mentioned.
The multiple thumbs on the first entry was just an example. I have also tried this individually.