Skip to content
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

Croppa not rotating images on crop #112

Open
LasseHaslev opened this issue Dec 14, 2015 · 8 comments
Open

Croppa not rotating images on crop #112

LasseHaslev opened this issue Dec 14, 2015 · 8 comments
Labels

Comments

@LasseHaslev
Copy link

I cannot make croppa auto rotate images in my laravel application. I use Homestead -v 2.1.4 and when i run the exif_imagetype function i get a valid callback, so i think exif should be installed.

@weotch
Copy link
Member

weotch commented Jan 22, 2016

Can you post the image that's not rotating for you?

@LasseHaslev
Copy link
Author

img_8153
I use iPhone 4s.
Seems like the image is not rotating here either. :)

@eberkund
Copy link

I also have this issue, images are not being auto-rotated based on the EXIF data. Here is the output from ExifTool for a sample image that is not working for me:

ExifTool Version Number         : 10.14
File Name                       : Hub_03_CAM_01.jpg
Directory                       : .
File Size                       : 5.1 MB
File Modification Date/Time     : 2016:04:18 14:04:44-04:00
File Access Date/Time           : 2016:04:18 14:04:44-04:00
File Creation Date/Time         : 2016:04:18 14:04:44-04:00
File Permissions                : rw-rw-rw-
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
Exif Byte Order                 : Little-endian (Intel, II)
Make                            : Canon
Camera Model Name               : Canon EOS REBEL T3i
Orientation                     : Rotate 90 CW
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Modify Date                     : 2011:12:02 20:36:58
Artist                          : 
Y Cb Cr Positioning             : Co-sited
Copyright                       : 
Exposure Time                   : 1/25
F Number                        : 16.0
Exposure Program                : Manual
ISO                             : 100
Sensitivity Type                : Recommended Exposure Index
Recommended Exposure Index      : 100
Exif Version                    : 0230
Date/Time Original              : 2011:12:02 20:36:58
Create Date                     : 2011:12:02 20:36:58
Components Configuration        : Y, Cb, Cr, -
Shutter Speed Value             : 1/25
Aperture Value                  : 16.0
Flash                           : Off, Did not fire
Focal Length                    : 50.0 mm
Macro Mode                      : Normal
Self Timer                      : Off
Quality                         : Fine
Canon Flash Mode                : Off
Continuous Drive                : Single
Focus Mode                      : Manual Focus (3)
Record Mode                     : JPEG
Canon Image Size                : Large
Easy Mode                       : Manual
Digital Zoom                    : None
Contrast                        : Normal
Saturation                      : Normal
Metering Mode                   : Evaluative
Focus Range                     : Not Known
Canon Exposure Mode             : Manual
Lens Type                       : Canon EF 50mm f/1.8 II
Max Focal Length                : 50 mm
Min Focal Length                : 50 mm
Focal Units                     : 1/mm
Max Aperture                    : 1.8
Min Aperture                    : 23
Flash Activity                  : 0
Flash Bits                      : (none)
Zoom Source Width               : 0
Zoom Target Width               : 0
Manual Flash Output             : n/a
Color Tone                      : Normal
Auto ISO                        : 100
Base ISO                        : 100
Measured EV                     : 8.75
Target Aperture                 : 16
Target Exposure Time            : 1/25
Exposure Compensation           : 0
White Balance                   : Flash
Slow Shutter                    : None
Shot Number In Continuous Burst : 0
Optical Zoom Code               : n/a
Camera Temperature              : 31 C
Flash Guide Number              : 0
Flash Exposure Compensation     : 0
Auto Exposure Bracketing        : Off
AEB Bracket Value               : 0
Control Mode                    : Camera Local Control
Measured EV 2                   : 8.75
Bulb Duration                   : 0
Camera Type                     : EOS High-end
ND Filter                       : n/a
Canon Image Type                : Canon EOS REBEL T3i
Canon Firmware Version          : Firmware Version 1.0.2
Flash Metering Mode             : Off
Camera Orientation              : Rotate 90 CW
Focus Distance Upper            : 0 m
Focus Distance Lower            : 0 m
Firmware Version                : 1.0.2
File Index                      : 470
Directory Index                 : 100
Contrast Standard               : 0
Sharpness Standard              : 3
Saturation Standard             : 0
Color Tone Standard             : 0
Contrast Portrait               : 0
Sharpness Portrait              : 2
Saturation Portrait             : 0
Color Tone Portrait             : 0
Contrast Landscape              : 0
Sharpness Landscape             : 4
Saturation Landscape            : 0
Color Tone Landscape            : 0
Contrast Neutral                : 0
Sharpness Neutral               : 0
Saturation Neutral              : 0
Color Tone Neutral              : 0
Contrast Faithful               : 0
Sharpness Faithful              : 0
Saturation Faithful             : 0
Color Tone Faithful             : 0
Contrast Monochrome             : 0
Sharpness Monochrome            : 3
Filter Effect Monochrome        : None
Toning Effect Monochrome        : None
Contrast Auto                   : 0
Sharpness Auto                  : 3
Saturation Auto                 : 0
Color Tone Auto                 : 0
Filter Effect Auto              : n/a
Toning Effect Auto              : n/a
Contrast User Def 1             : 0
Sharpness User Def 1            : 3
Saturation User Def 1           : 0
Color Tone User Def 1           : 0
Filter Effect User Def 1        : None
Toning Effect User Def 1        : None
Contrast User Def 2             : 0
Sharpness User Def 2            : 3
Saturation User Def 2           : 0
Color Tone User Def 2           : 0
Filter Effect User Def 2        : None
Toning Effect User Def 2        : None
Contrast User Def 3             : 0
Sharpness User Def 3            : 3
Saturation User Def 3           : 0
Color Tone User Def 3           : 0
Filter Effect User Def 3        : None
Toning Effect User Def 3        : None
User Def 1 Picture Style        : Auto
User Def 2 Picture Style        : Auto
User Def 3 Picture Style        : Auto
Canon Model ID                  : EOS Rebel T3i / 600D / Kiss X5
Thumbnail Image Valid Area      : 0 159 7 112
AF Area Mode                    : Off (Manual Focus)
Num AF Points                   : 9
Valid AF Points                 : 9
Canon Image Width               : 5184
Canon Image Height              : 3456
AF Image Width                  : 5184
AF Image Height                 : 3456
AF Area Widths                  : 139 139 139 196 238 196 139 139 139
AF Area Heights                 : 186 186 186 127 231 127 186 186 186
AF Area X Positions             : -1477 -886 -886 0 0 0 886 886 1477
AF Area Y Positions             : 0 418 -418 787 0 -787 418 -418 0
AF Points In Focus              : (none)
AF Points Selected              : 0,1,2,3,4,5,6,7,8
Original Decision Data Offset   : 0
Bracket Mode                    : Off
Bracket Value                   : 0
Bracket Shot Number             : 0
Raw Jpg Size                    : Large
Long Exposure Noise Reduction 2 : Off
WB Bracket Mode                 : Off
WB Bracket Value AB             : 0
WB Bracket Value GM             : 0
Live View Shooting              : Off
Flash Exposure Lock             : Off
Internal Serial Number          : ZC4353398
Dust Removal Data               : (Binary data 1024 bytes, use -b option to extract)
Crop Left Margin                : 0
Crop Right Margin               : 0
Crop Top Margin                 : 0
Crop Bottom Margin              : 0
Exposure Level Increments       : 1/3 Stop
ISO Expansion                   : Off
Flash Sync Speed Av             : Auto
Long Exposure Noise Reduction   : Off
High ISO Noise Reduction        : Standard
Highlight Tone Priority         : Disable
AF Assist Beam                  : Emits
Mirror Lockup                   : Enable
Shutter-AE Lock                 : AF/AE lock
Set Button When Shooting        : Normal (disabled)
LCD Display At Power On         : Display
Add Original Decision Data      : Off
Aspect Ratio                    : 3:2
Cropped Image Width             : 5184
Cropped Image Height            : 3456
Cropped Image Left              : 0
Cropped Image Top               : 0
Tone Curve                      : Standard
Sharpness                       : 3
Sharpness Frequency             : n/a
Sensor Red Level                : 0
Sensor Blue Level               : 0
White Balance Red               : 0
White Balance Blue              : 0
Color Temperature               : 5200
Picture Style                   : Auto
Digital Gain                    : 0
WB Shift AB                     : 0
WB Shift GM                     : 0
Measured RGGB                   : 638 1024 1024 649
VRD Offset                      : 0
Sensor Width                    : 5344
Sensor Height                   : 3516
Sensor Left Border              : 152
Sensor Top Border               : 56
Sensor Right Border             : 5335
Sensor Bottom Border            : 3511
Black Mask Left Border          : 0
Black Mask Top Border           : 0
Black Mask Right Border         : 0
Black Mask Bottom Border        : 0
Color Data Version              : 10 (600D/1200D)
WB RGGB Levels As Shot          : 2378 1024 1024 1448
Color Temp As Shot              : 6327
WB RGGB Levels Auto             : 2389 1024 1024 1322
Color Temp Auto                 : 7103
WB RGGB Levels Measured         : 2389 1024 1024 1322
Color Temp Measured             : 7103
WB RGGB Levels Daylight         : 2131 1024 1024 1594
Color Temp Daylight             : 5200
WB RGGB Levels Shade            : 2450 1024 1024 1358
Color Temp Shade                : 7000
WB RGGB Levels Cloudy           : 2289 1024 1024 1467
Color Temp Cloudy               : 6000
WB RGGB Levels Tungsten         : 1540 1024 1024 2372
Color Temp Tungsten             : 3200
WB RGGB Levels Fluorescent      : 1876 1024 1024 2250
Color Temp Fluorescent          : 3729
WB RGGB Levels Kelvin           : 2131 1024 1024 1594
Color Temp Kelvin               : 5200
WB RGGB Levels Flash            : 2378 1024 1024 1448
Color Temp Flash                : 6327
Average Black Level             : 2048 2048 2048 2048
Raw Measured RGGB               : 367939 577402 576241 355560
Per Channel Black Level         : 2047 2048 2048 2048
Specular White Level            : 12279
Linearity Upper Margin          : 10000
Custom Picture Style File Name  : 
Vignetting Corr Version         : 0
Peripheral Lighting             : Off
Chromatic Aberration Corr       : Off
Peripheral Lighting Value       : 0
Original Image Width            : 5184
Original Image Height           : 3456
Peripheral Lighting Setting     : Off
Peripheral Illumination Corr    : Off
Auto Lighting Optimizer         : Off
Ambience Selection              : Standard
User Comment                    : 
Sub Sec Time                    : 49
Sub Sec Time Original           : 49
Sub Sec Time Digitized          : 49
Flashpix Version                : 0100
Color Space                     : sRGB
Exif Image Width                : 5184
Exif Image Height               : 3456
Interoperability Index          : R98 - DCF basic file (sRGB)
Interoperability Version        : 0100
Focal Plane X Resolution        : 5728.176796
Focal Plane Y Resolution        : 5808.403361
Focal Plane Resolution Unit     : inches
Custom Rendered                 : Normal
Exposure Mode                   : Manual
Scene Capture Type              : Standard
Owner Name                      : 
Serial Number                   : 402178091900
Lens Info                       : 50mm f/?
Lens Model                      : EF50mm f/1.8 II
Lens Serial Number              : 0000000000
Compression                     : JPEG (old-style)
Thumbnail Offset                : 8928
Thumbnail Length                : 9184
Rating                          : 0
Image Width                     : 5184
Image Height                    : 3456
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:2 (2 1)
Aperture                        : 16.0
Drive Mode                      : Single-frame Shooting
File Number                     : 100-0470
Image Size                      : 5184x3456
Lens                            : 50.0 mm
Lens ID                         : Canon EF 50mm f/1.8 II
Megapixels                      : 17.9
Scale Factor To 35 mm Equivalent: 1.6
Shooting Mode                   : Manual
Shutter Speed                   : 1/25
Create Date                     : 2011:12:02 20:36:58.49
Date/Time Original              : 2011:12:02 20:36:58.49
Modify Date                     : 2011:12:02 20:36:58.49
Thumbnail Image                 : (Binary data 9184 bytes, use -b option to extract)
WB RGGB Levels                  : 2378 1024 1024 1448
Blue Balance                    : 1.414063
Circle Of Confusion             : 0.019 mm
Depth Of Field                  : inf (0.00 m - inf)
Field Of View                   : 25.8 deg
Focal Length                    : 50.0 mm (35 mm equivalent: 78.6 mm)
Hyperfocal Distance             : 8.18 m
Lens                            : 50.0 mm (35 mm equivalent: 78.6 mm)
Light Value                     : 12.6
Red Balance                     : 2.322266

@weotch
Copy link
Member

weotch commented Sep 8, 2016

Ok, I see the problem. The exif_read_data function needs to read from the filesystem. But in Croppa 4, with the switch to supporting Flysystem, I'm interacting with raw image data throughout. I don't necessarily have a path to a file, like if the file was on a remote filesystem.

Maybe I can do something like this: http://stackoverflow.com/a/5465741/59160. Or I need to save the image locally, like to a /tmp directory, while doing the image manipulations. Which is what I'll need to do if I DO switch to Intervention ( #110 ), which has the same issue:

@weotch weotch added the bug label Sep 8, 2016
@GerTea
Copy link

GerTea commented Mar 6, 2018

@weotch Any news on this issue? I just got this issue and don't really know what to do with it :/
Does it make sense to rotate the image right at upload so that the information is not really needed afterwards? What do you think?
Or are you planning on changing this any time soon?

@weotch
Copy link
Member

weotch commented Mar 6, 2018

I don't see myself working on it myself right now, but I'd take a PR. Or, like you suggest, you could apply the EXIF rotations immediately on file upload independent of Croppa.

@ataylor32
Copy link

Croppa uses the weotch fork of PHPThumb, which is no longer accepting pull requests for the 1.0 branch. I came up with a workaround, but for all I know I'm doing something horrible or there are scenarios I'm not aware of in which this wouldn't be good to do, so use this workaround with caution.

First, change the ThumbBase class' isDataStream property from protected to public.

Second, replace this line from the JpgImageRotation class' rotateJpg method:

Old:

$exif = @exif_read_data($this->parentInstance->getFilename());

New:

if ($this->parentInstance->isDataStream) {
    $stream = fopen('php://temp', 'r+');
    fwrite($stream, $this->parentInstance->getFilename());
    rewind($stream);
    $exif = @exif_read_data($stream);
}
else {
    $exif = @exif_read_data($this->parentInstance->getFilename());
}

@miking7
Copy link

miking7 commented Nov 8, 2022

I experienced this same issue, and have prepared a pull request to resolve it by copying the remote file to a temporary disk if desired.

See: #210

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants