Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Posts
    428
    Thanks
    0
    Thanked 20 Times in 20 Posts

    exif unable to access error

    Ok I tried a google search for the following error:
    'Warning: exif_read_data() [function.exif-read-data]: Unable to access'
    and got 5,370 results, which are actually errors loged into google during a website's developement. (complete with pathways!)

    Anyway I just treied a new script I found on the net and am getting the above error. What do I need to check or adjust. Note I do not have access to the main php.ini file because we are currently on a shared hosting plan so I cannot check or change the extension loading order as php.net described. Any other options?
    NO Limits!! www.dhcreationstation.com
    ------------------------------------------------------------
    Broken items wanted for tinkerin'! PostItNow@BrokenEquipment.com

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,978
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    I can verify after on a windows machine, but I seem to recall doing this in the past and the exif library wouldn't load at all without the presence of the mb_string libraries. That of course only applies in a windows environment and not a linux one.
    Pretty generic; what's the result of an is_readable() call to the same file path? Unable to access sounds to be of either no file found or no permissions to read.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    2,958
    Thanks
    2
    Thanked 304 Times in 296 Posts
    You should have been getting a second warning after that one that gave more information about why the function couldn't access the file.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #4
    Regular Coder
    Join Date
    Sep 2002
    Posts
    428
    Thanks
    0
    Thanked 20 Times in 20 Posts
    I found this script online that should auto detect an images orientation (cell phone image posting ) and auto correct (rotate) it for storage. It hooked to the upload processor which is shown in the call below.

    Errors:
    Warning: exif_read_data() [function.exif-read-data]: Unable to access myimage.jpg in /mypath/myfile.php on line 377

    Warning: exif_read_data() [function.exif-read-data]: Unable to open file in /mypath/myfile.php on line 377

    Warning: Cannot modify header information - headers already sent by (output started at mypath/myfile.php:377) in /mypath/myfile.php on line 574
    I figured the added errors are just a cascade effect...until I can prove differently.

    The functions:
    function _mirrorImage ( $imgsrc)
    {
    $width = imagesx ( $imgsrc );
    $height = imagesy ( $imgsrc );

    $src_x = $width -1;
    $src_y = 0;
    $src_width = -$width;
    $src_height = $height;

    $imgdest = imagecreatetruecolor ( $width, $height );

    if ( imagecopyresampled ( $imgdest, $imgsrc, 0, 0, $src_x, $src_y, $width, $height, $src_width, $src_height ) )
    {
    return $imgdest;
    }

    return $imgsrc;
    }

    function adjustPicOrientation($full_filename){
    $exif = exif_read_data($full_filename);
    if($exif && isset($exif['Orientation'])) {
    $orientation = $exif['Orientation'];
    if($orientation != 1){
    $img = imagecreatefromjpeg($full_filename);

    $mirror = false;
    $deg = 0;

    switch ($orientation) {
    case 2:
    $mirror = true;
    break;
    case 3:
    $deg = 180;
    break;
    case 4:
    $deg = 180;
    $mirror = true;
    break;
    case 5:
    $deg = 270;
    $mirror = true;
    break;
    case 6:
    $deg = 270;
    break;
    case 7:
    $deg = 90;
    $mirror = true;
    break;
    case 8:
    $deg = 90;
    break;
    }
    if ($deg) $img = imagerotate($img, $deg, 0);
    if ($mirror) $img = _mirrorImage($img);
    $full_filename = str_replace('.jpg', "-O$orientation.jpg", $full_filename);
    imagejpeg($img, $full_filename, 95);
    }
    }
    return $full_filename;
    }


    The Call:
    $upload_status = move_uploaded_file($File_Src,$_IMGPATH.$File_Name);
    if($upload_status){
    $new_name = $File_UploadTime.$File_Num.$File_Ext;
    //----- Auto Detect & Rotate -----//
    $new_name = adjustPicOrientation($new_name);
    Last edited by c1lonewolf; 06-12-2013 at 07:01 PM.
    NO Limits!! www.dhcreationstation.com
    ------------------------------------------------------------
    Broken items wanted for tinkerin'! PostItNow@BrokenEquipment.com

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,978
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    And there's your cause: Warning: exif_read_data() [function.exif-read-data]: Unable to open file in /mypath/myfile.php on line 377.
    What is the relationship between:
    $GENESYS_IMGPATH . $File_Name
    and
    $File_UploadTime . $File_Num . $File_Ext
    ?
    Since $new_name is that of the second line and is used in adjustPicOrientation, I'm curious how the file got there. The move is issued a path under the $GENESYS_IMGPATH, so unless the $new_name matches that of the uploaded path to, than I can't see it existing in the location provided under the $new_name.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #6
    Regular Coder
    Join Date
    Sep 2002
    Posts
    428
    Thanks
    0
    Thanked 20 Times in 20 Posts
    The 'GENESYS_IMGPATH' is where the files are stored. See my mark and reduce function returns true after it has added the watermarks and creates a thumbnail. Theirs return the file name which is throwing me off.

    $File = $_FILES['uploaded'];
    $File_Src = $File['tmp_name'][$i];
    $File_Name = $File['name'][$i];
    //$File_Size = $File['size'][$i]; //not required once validated
    //$File_Type = $File['type'][$i]; //not required once validated

    $File_Field = ($i+1);
    $File_Num = '_'.$File_Field;
    $File_WMText = $File_UploadTime.$File_Num;
    $File_Ext = '.'.extend($File_Name);

    $upload_status = move_uploaded_file($File_Src,$GENESYS_IMGPATH.$File_Name);
    if($upload_status){
    $new_name = $File_UploadTime.$File_Num.$File_Ext;

    //$new_name = adjustPicOrientation($new_name);

    if(!genesys_MarknReduceImage($GENESYS_IMGPATH.$File_Name, $new_name, $File_WMText)){
    $form_error_message = 'Imaging Error!';
    }
    NO Limits!! www.dhcreationstation.com
    ------------------------------------------------------------
    Broken items wanted for tinkerin'! PostItNow@BrokenEquipment.com

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,978
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    That's fine, but you should note that both the move_uploaded_file and genesys_marknreduceimage appear to use the path $GENESYS_IMGPATH . $File_Name whilst the adjustPicOrientation uses $new_name. These do not appear to be the same; at what point is the file denoted by $File_UploadTime . $File_Num . $File_Ext created?
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #8
    Regular Coder
    Join Date
    Sep 2002
    Posts
    428
    Thanks
    0
    Thanked 20 Times in 20 Posts
    Thanks for the clue Fou-Lu. I coudn't find where to delete this thread after so many entries. But thanks
    NO Limits!! www.dhcreationstation.com
    ------------------------------------------------------------
    Broken items wanted for tinkerin'! PostItNow@BrokenEquipment.com

  • #9
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,899
    Thanks
    15
    Thanked 226 Times in 226 Posts
    It sound like a path problem to me, look at your working scripts and see how the path is defined for them. Then do it the same way for the new one. If the person writing the script was any good the path would be defined at the top, so you would only need to change that.
    Welcome to http://www.myphotowizard.net

    where you can edit images, make a photo calendar, add text to images, and do much more.


    When you know what you're doing it's called Engineering, when you don't know, it's called Research and Development. And you can always charge more for Research and Development.

  • #10
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,089
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Hehehe.. any excuse to play with the postimage.org screen capture / upload tool..



    That means you have no excuse not to do this!:
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •