ImageConverter not converting image on localserver

Hey @seehat, I finally came across your awesome plugin to resize some images when they’re uploaded to the panel, but I think I’m having a similar issue with this guy, but nothing seems to be wrong with MAMP.

ImageMagick is installed with homebrew and function_exists('exec') confirmed that ‘exec’ is allowed

I have the below code setup in my config file just to make sure something is working, but I’m not even getting a new image with ‘_resized’ added to the file name.

c::set('thumbs.driver', 'im');

kirby()->hook('panel.file.upload', function($file) {
    if ($file->type() == 'image') {
        $image = new ImageConverter($file, array(
          'filename' => '{name}_resized.{extension}'
        ));
        $image->process();
    }
});

what could I be doing wrong?

Have you tried to use ImageMagick for simple thumb creation instead of using the plugin and does this work? If not, I guess there might be a problem with the ImageMagick setup, see this thread How to switch from GD to ImageMagic as image engine?

1 Like

I got the plugin to work fine on a remote server, just like in the other post I linked too, but only on ‘panel.file.update’ and not ‘panel.file.upload’

kirby()->hook('panel.file.upload', function($file) {
    $page = $file->page();
    $title = $page->slug();
    resize($file, $title);
});

kirby()->hook('panel.file.update', function($file) {
    $page = $file->page();
    $title = $page->slug();
    resize($file, $title);
});


function resize($file, $title) {
$large = new ImageConverter($file, array(
    'width' => 700,
    'height' => 1200,
    'upscale' => true,
    'tosRGB' => true,
    'filename' => $title . '-large.{extension}',
));
$large->process();

$medium = new ImageConverter($file, array(
    'width' => 466,
    'height' => 800,
    'upscale' => true,
    'tosRGB' => true,
    'filename' => $title . '-medium.{extension}',
));
$medium->process();

$small = new ImageConverter($file, array(
    'width' => 270,
    'height' => 450,
    'upscale' => true,
    'tosRGB' => true,
    'filename' => $title . '-small.{extension}',
));
$small->process();

$original = new ImageConverter($file, array(
    'tosRGB' => true,
    'filename' => $title . '.{extension}',
));
$original->process();
}

any reason why it wouldn’t trigger for the upload hook? is it possible that one of the arguments isn’t passing through?

@texnixe I tried the suggestions in that link, same result :confused:
thanks though!

Hey, thx for using my plugin.

Maybe there is something wrong with your kirby install. Have tried using a default thumb function for resizing an image in your panel.file.upload hook, or a different function call to check, if panel.file.upload is called successfully?

1 Like

I’m not even sure of what other functions can be called in a hook. Is there anything simple with an easily visible output?

Here is an example, it creates a text file called test.txt in /content with the filename of the uploaded file.

kirby()->hook('panel.file.upload', 'run');

function run( $image ) {
	$path = kirby()->roots()->content();

	$content = '';
	$content .= $image->kirby()->page() . "\n";
	$content .= $image->name();

	file_put_contents( $path . '/test.txt', $content );
}

taking back everything this comment just said, FTP client wasn’t actually refreshing when I hit refresh

The file is being created with update but still not upload, I’m really not sure what this could mean

I suggest you do a fresh install of Kirby core and panel to make sure that everything is as it should be.

1 Like

Aahhhhh yes! the upload hook gets triggered!!

Note: this still only happens on the server and none of my hooks get triggered locally. I’m not asking for assistance on this since it’s easy to work around it, but just thought I’d let y’all know

Thanks so much @texnixe and @seehat :heart_eyes: