phpThumb not working with AWS S3 bucket as media source

I’ve changed media source from file system to S3 bucket, after that phpThumb is failing to generate thumbnails in manager and on the site.

I’ve set url, bucket name, key, secret key and region. I can see that connection to S3 bucket works as I can see a list of files and directories in media browser and also upload/update files.

Observed behavior

I thought that file names could be a reason, but I uploaded test.jpg file and it still didn’t created thumbnail.

This is fragment of my error log

[2019-04-16 22:23:05] (ERROR @ /var/www/html/core/model/modx/sources/mods3mediasource.class.php : 558) Thumbnail could not be created for file: s3host/bucketname/8,Królowa Wangnea,żona wodza Khaopa z wioski Sheanghah…jpg
[2019-04-16 22:23:05] (ERROR @ /var/www/html/core/model/modx/sources/mods3mediasource.class.php : 558) Thumbnail could not be created for file: s3host/bucketname/9,Chata wojowników Konyak.jpg
[2019-04-16 22:23:05] (ERROR @ /var/www/html/core/model/modx/sources/mods3mediasource.class.php : 558) Thumbnail could not be created for file: s3host/bucketname/KINGDOM OF LO.jpg
[2019-04-16 22:23:06] (ERROR @ /var/www/html/core/model/phpthumb/phpthumb.class.php : 3654) PHP warning: filesize(): stat failed for https://s3-us-west-2.amazonaws.com/bucketname/2,Nagaland.jpg
[2019-04-16 22:23:06] (ERROR @ /var/www/html/core/model/phpthumb/phpthumb.class.php : 3654) PHP warning: filesize(): stat failed for https://s3-us-west-2.amazonaws.com/bucketname/test.jpg
[2019-04-16 22:23:06] (ERROR @ /var/www/html/core/model/phpthumb/modphpthumb.class.php : 144) phpThumb was unable to generate a thumbnail for: /var/www/html/core/cache/phpthumb/edbochnak.pl__srcf38e06c01e28c92c3cb92f06c359c559_pare23411d0821ae56bf50a1f79d182c074_dat0.ico
[2019-04-16 22:23:06] (ERROR @ /var/www/html/core/model/phpthumb/modphpthumb.class.php : 156) Error outputting thumbnail:
OutputThumbnail() failed because !is_resource($this->gdimg_output) in file “phpthumb.class.php” on line 618
[2019-04-16 22:23:06] (ERROR @ /var/www/html/core/model/phpthumb/modphpthumb.class.php : 144) phpThumb was unable to generate a thumbnail for: /var/www/html/core/cache/phpthumb/edbochnak.pl__srcb7d9cd9c645cbc744a2fcd5d8683821f_pare23411d0821ae56bf50a1f79d182c074_dat0.ico
[2019-04-16 22:23:06] (ERROR @ /var/www/html/core/model/phpthumb/modphpthumb.class.php : 156) Error outputting thumbnail:
OutputThumbnail() failed because !is_resource($this->gdimg_output) in file “phpthumb.class.php” on line 618

MODX Revolution 2.6.5-pl
PHP Version 7.0.24
Mysql 5.6.10

I presume it has to upload the image, process it, generate a thumbnail, and then save the thumbnail somewhere. Is it trying to write the thumbnails to AWS?

1 Like

Yes, my understanding is that it should work same way as with file system. I can confirm that modx has permissions to write to S3 and I can upload new files through media browser, only generating thumbnails is failing.

Do you have GD installed and working?

Assuming this is MODX 2.x, I see this in code: