milesj / uploader

[Deprecated] A CakePHP plugin for file uploading and validating.
MIT License
193 stars 73 forks source link

Exif Data & Resize->expand #157

Closed wilsmex closed 10 years ago

wilsmex commented 10 years ago

I've got stuck on two issues, and tried a thousand configurations..

What I'm wanting: 1)Image uploads -> gets resized to 2 different thumbnails & original gets sized as well 2)Exif data gets saved 3) Bonus: is is possible to have the transform->resize 'mode' set to 'auto' where it will resize the image to the width & height that I've set according to whichever is longer?

What I'm getting: 1) Images upload, original size won't scale up past 1080px unless I set the 'expand' flag to true. (even though original image is well over 3000px on both sides..)

2) If I set the 'self' => true no exif data gets added with the image. Setting true to false, exif uploads without issues

I could be missing something obvious on my config...

Partial config dump:

'file_path' => array(
                'overwrite' => false,
                'stopSave' => true,
                'transforms' => array(
                    'resize_small' => array(
                        'class' => 'resize', // or crop
                        'aspect' => true,
                        'overwrite' => false,
                        'width' => 100,
                        'height' => 100,
                        'quality' => 80,
                        'mode' => 'width'
                    ),
                    'resize_medium' => array(
                        'class' => 'resize',
                        'aspect' => true,
                        'overwrite' => false,
                        'width' => 540,
                        'height' => 540,
                        'quality' => 80,
                        'mode' => 'width'
                    ),
                    'resize_large' => array(
                        'class' => 'resize',
                        'aspect' => true,
                        'overwrite' => false,
                        'width' => 1920,
                        'height' => 1920,
                        'self' => true, //this should be true TODO with false it shows exif.. not sure whats up.
                        'quality' => 80,
                        'mode' => 'width',
                        'expand' => false // without setting this to true, this transform is limited to 1080px, even though the original is 3000px+ on each side
                    )
milesj commented 10 years ago

Transforming an image in anyway will remove exif data, so setting self to true will remove the exif data, this is normal and not something I'm doing, it's just part of the image rewrite process internally.

Can you past the whole behavior configuration code so I can test locally?

wilsmex commented 10 years ago

That's what I was thinking. I played a bit with the settings, and now can get my full-size image to resize past 1080, but I still don't get the exif data. I've included the 'exif' transformation as per your instructions. The config file dump below doesn't give me exif data.

If I set the 'resize_large' rule to self -> false, then I do get the exif data... Very slick plugin BTW.


public $actsAs = array(
        'Uploader.Attachment' => array(
            'file_path' => array(
                'overwrite' => false,
                'stopSave' => true,
                'transforms' => array(
                    array(
                        'class' => 'exif',
                        'self' => true // doesn't give any exif?..
                    ),
                    'resize_small' => array(
                        'class' => 'resize',
                        'aspect' => true,
                        'overwrite' => false,
                        'width' => 100,
                        'height' => 100,
                        'quality' => 80,
                        'mode' => 'width'
                    ),
                    'resize_medium' => array(
                        'class' => 'resize',
                        'aspect' => true,
                        'overwrite' => false,
                        'width' => 1080,
                        'height' => 1080,
                        'quality' => 80,
                        'mode' => 'width'   
                    ),
                    'resize_large' => array(
                        'class' => 'resize',
                        'aspect' => true,
                        'overwrite' => false,
                        'width' => 1920,
                        'height' => 1920,
                        'self' => true, //this should be true TODO with false exif data gets added.. not sure..?
                        'quality' => 80,
                        'mode' => 'width',
                        'expand' => false
                    )

                ),
                'transport' => array(
                                'class' => AttachmentBehavior::S3,
                                'accessKey' => 'awskey',
                                'secretKey' => 'awssecret',
                                'bucket' => 'awsbucket',
                                'region' => Aws\Common\Enum\Region::US_EAST_1,
                                'folder' => IMAGE_AWS_FINAL_PATH
                            ),
                'tempDir' => TMP,
                'uploadDir' => IMAGE_SITE_UPLOAD_DIR,
                'finalPath' => IMAGE_FINAL_PATH,
                'metaColumns' => array( 
                    'ext' => 'file_extension',
                    'type' => 'file_type',
                    'size' => 'file_size',
                    'type' => 'file_type',
                    'basename' => 'base_name',
                    'name' => 'file_name',
                    'width' => 'width',
                    'height' => 'height',
                    'exif.make' => 'exif_make',
                    'exif.model' => 'exif_model',
                    'exif.exposure' => 'exif_exposure',
                    'exif.orientation' => 'exif_orientation',
                    'exif.fnumber' => 'exif_fnumber',
                    'exif.date' => 'exif_date',
                    'exif.iso' => 'exif_iso',
                    'exif.focal' => 'exif_focal'    

                ),
                'nameCallback' => 'formatUploadFileName'
            )
        ),
        'Uploader.FileValidation' => array(
            'file_path' => array(
                'maxWidth'  => 4600,
                'maxHeight' => 4600,
                'minWidth'  => 540,
                'minHeight' => 540,
                'extension' => array('gif', 'jpg', 'png', 'jpeg','mov'),
                'mimeType'  => array('image/gif','image/jpg','image/png','image/jpeg'),
                'type'      => array('image'),
                'filesize'  => 5242880,
                'required' => false
            )
        )
    );
milesj commented 10 years ago

It looks like I'm fetching the meta data after transforms occur, hence the exif data being missing from the original. Will have to do it before and after.

milesj commented 10 years ago

This will be fixed in the next tag.