-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
imagecopyresampled(): supplied resource is not a valid Image resource #689
Comments
I won't have time to look into this until later today, but I would guess it's due to how you're calling
|
\Config\Services::image( 'gd', null, false) Is what I ended up doing. But I feel like withFile would basically "refresh" that class? I felt it was a hacky way of doing it. This is how I was using it in my code. I spent a few hours getting it to "work". I left that area alone and I'll look into later. $handler = \Config\Services::image( 'gd', null, false )
->withFile( "{$folderPath}/{$this->fileName}.{$this->extension}" );
$info = $this->handler->getFile()
->getProperties( true );
if ($info['width'] <= $info['height']) {
$width = $info['width'];
$height = $info['width'];
} else {
$width = $info['height'];
$height = $info['height'];
}
$xOffset = ( $info['width'] / 2 ) - ( $width / 2 );
$yOffset = ( $info['height'] / 2 ) - ( $height / 2 );
$handler->withFile( "{$folderPath}/{$this->fileName}.{$this->extension}" )
->crop( $width, $height, $xOffset, $yOffset )
->resize( 500, 500 )
->save( "{$folderPath}/thumb_{$this->fileName}.{$this->extension}" );
$this->thumbnail = "{$this->webPath}/thumb_{$this->fileName}.{$this->extension}";
foreach ($this->sizes as $size) {
$this->{'x' . $size} = "{$this->webPath}/{$this->fileName}x{$size}.{$this->extension}";
$handler = \Config\Services::image( 'gd', null, false )
->withFile( "{$folderPath}/{$this->fileName}.{$this->extension}" )
->resize( $size, $size )
->save( "{$folderPath}/{$this->fileName}x{$size}.{$this->extension}",100 );
}
return $this; |
You're right, it does make sense. And looking at the code, |
I have tried multiple code setups for the image class and I cannot get it working, the way I need it to. I can do one file at a time. If I want to create thumbnails it errors. These are the setups I've tried. I have been digging through the class trying to find where it goes wrong, but I can't find it anywhere.
The text was updated successfully, but these errors were encountered: