D
D
Dmitry2019-03-21 00:25:36
Yii
Dmitry, 2019-03-21 00:25:36

Error opening imagine. How to fix?

Goodnight.
I ran into a problem that I don't understand.
There is a console application that parses ads from a remote server. The ads have pictures.
First, images are uploaded to a temporary directory, then resized, reduced copies are created, and finally transferred to a permanent directory.
But after several iterations of the loop, an error is displayed:

Exception 'Imagine\Exception\RuntimeException' with message 'Unable to open image /home/slonik/localhost/www/test.loc/prodejvuz/frontend/web/cars/tmp_upload/9/6O35536.jpg'

The image itself exists. All previous images have been resized and previewed.
There are no problems with access rights.
Here is the output of the ls -l command
-rw-rw-r-- 1 slonik slonik  64344 мар 20 23:04 0O35536.jpg
-rw-rw-r-- 1 slonik slonik  67230 мар 20 23:04 1O35536.jpg
-rw-rw-r-- 1 slonik slonik  56515 мар 20 23:04 2O35536.jpg
-rw-rw-r-- 1 slonik slonik  59062 мар 20 23:04 3O35536.jpg
-rw-rw-r-- 1 slonik slonik  74374 мар 20 23:04 4O35536.jpg
-rw-rw-r-- 1 slonik slonik  31160 мар 20 23:04 5O35536.jpg
-rw-rw-r-- 1 slonik slonik 216203 мар 20 23:04 6O35536.jpg
drwxr-xr-x 1 slonik slonik    132 мар 20 23:04 mini

Problem with image 6O35536.jpg . So far, all images from 0O35536.jpg to 5O35536.jpg have been resized and reduced in size and placed in the "mini" directory.
Methods that are responsible for resizing and creating previews.
public static function resizeImg($dir, $file, $path=null)
{
    foreach($file as $value){
        if($value != 'mini' && (mime_content_type($path . $value) == 'image/jpeg')){
            Image::resize($path . $value, 1200, null)->save($path . $value, ['jpeg_quality' => 80]);
            self::thumbnail($value, $path);
            Images::writeImg($value, $dir);
        }
        else{
            continue;
        }
    }
}

public static function thumbnail($file, $path)
{
    if(!file_exists($path . 'mini/')){
        mkdir($path . 'mini', 0755);
    }
    Image::thumbnail($path . $file, 274, 210)->save($path . 'mini/' . $file);
}

What could be the reason for stopping the script? After all, the image exists, there are read rights, and the previous images were processed without problems.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question