Jump to content

Barand

Moderators
  • Posts

    24,425
  • Joined

  • Last visited

  • Days Won

    806

Posts posted by Barand

  1. TABLE addya                                TABLE addyb
    +----+-----------+-----------+             +----+-----------+-----------+
    | id | address1  | address2  |             | id | address1  | address2  |
    +----+-----------+-----------+             +----+-----------+-----------+
    |  1 | add A 1 1 | add A 1 2 |             |  1 | add B 1 1 | add B 1 2 |
    |  2 | add A 2 1 | add A 2 2 |             |  2 | NULL      | NULL      |
    |  3 | NULL      | NULL      |             |  3 | add B 3 1 | add B 3 2 |
    +----+-----------+-----------+             +----+-----------+-----------+
    
    SELECT id
         , COALESCE(a.address1, b.address1) as add1
         , COALESCE(a.address2, b.address2) as add2
    FROM addya a 
            JOIN
         addyb b USING(id);   
    
    +----+-----------+-----------+
    | id | add1      | add2      |
    +----+-----------+-----------+
    |  1 | add A 1 1 | add A 1 2 |
    |  2 | add A 2 1 | add A 2 2 |
    |  3 | add B 3 1 | add B 3 2 |
    +----+-----------+-----------+

     

  2. 1 minute ago, phppup said:

    So during the upload process, rotation needs to be handled before resizing?

    Yes, or do them both in the same operation.

     

    2 minutes ago, phppup said:

    No way to retain the EXIF data?

    Not in the image. If you store the original image then you can still get it any time you want it.. You would have to amend your rotation function as it currently overwrites the input file.

  3. 38 minutes ago, phppup said:

    [COMMENT] => Array ( [0] => CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 80 )

    From your "BEFORE" exif data (above) it was created by GD library in PHP. Uploading should just copy the file. Are you doing any PHP processing on the file after uploading, such as resizing?

    My image was copied from my camera to my PC.

  4. 12 minutes ago, phppup said:
    
    BEFORE
    
    Array
    (
        [FileName] => myTest.jpg
        [FileDateTime] => 1574967654
        [FileSize] => 12566
        [FileType] => 2
        [MimeType] => image/jpeg
        [SectionsFound] => COMMENT
        [COMPUTED] => Array
            (
                [html] => width="500" height="244"
                [Height] => 244
                [Width] => 500
                [IsColor] => 1
            )
    
        [COMMENT] => Array
            (
                [0] => CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 80
    
            )
    
    )
    
    AFTER
    
    Array
    (
        [FileName] => myTest.jpg
        [FileDateTime] => 1574967654
        [FileSize] => 12566
        [FileType] => 2
        [MimeType] => image/jpeg
        [SectionsFound] => COMMENT
        [COMPUTED] => Array
            (
                [html] => width="500" height="244"
                [Height] => 244
                [Width] => 500
                [IsColor] => 1
            )
    
        [COMMENT] => Array
            (
                [0] => CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 80
    
            )
    
    )

     

    I don't see any "orientation" index in your exif data.

    My "BEFORE" exif data looks like this (as you can see, orientation = 8)...

    Array
    (
        [FileName] => DSCN0035.JPG
        [FileDateTime] => 1528993833
        [FileSize] => 4044525
        [FileType] => 2
        [MimeType] => image/jpeg
        [SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF, GPS, INTEROP, MAKERNOTE
        [COMPUTED] => Array
            (
                [html] => width="4896" height="3672"
                [Height] => 3672
                [Width] => 4896
                [IsColor] => 1
                [ByteOrderMotorola] => 0
                [ApertureFNumber] => f/5.8
                [UserComment] =>                                                                                                                        
                [UserCommentEncoding] => UNDEFINED
                [Thumbnail.FileType] => 2
                [Thumbnail.MimeType] => image/jpeg
            )
    
        [ImageDescription] =>           
        [Make] => NIKON
        [Model] => COOLPIX P520
        [Orientation] => 8                                               <<*************** ORIENTATION **************
        [XResolution] => 300/1
        [YResolution] => 300/1
        [ResolutionUnit] => 2
        [Software] => COOLPIX P520   V1.0
        [DateTime] => 2014:06:30 13:33:43
        [YCbCrPositioning] => 2
        [Exif_IFD_Pointer] => 314
        [GPS_IFD_Pointer] => 1002
        [THUMBNAIL] => Array
            (
                [Compression] => 6
                [XResolution] => 300/1
                [YResolution] => 300/1
                [ResolutionUnit] => 2
                [JPEGInterchangeFormat] => 4032
                [JPEGInterchangeFormatLength] => 4658
            )
    
        [ExposureTime] => 10/6400
        [FNumber] => 58/10
        [ExposureProgram] => 3
        [ISOSpeedRatings] => 80
        [UndefinedTag:0x8830] => 1
        [ExifVersion] => 0230
        [DateTimeOriginal] => 2014:06:30 13:33:43
        [DateTimeDigitized] => 2014:06:30 13:33:43
        [ComponentsConfiguration] => 
        [CompressedBitsPerPixel] => 2/1
        [ExposureBiasValue] => 0/10
        [MaxApertureValue] => 32/10
        [MeteringMode] => 5
        [LightSource] => 0
        [Flash] => 16
        [FocalLength] => 356/10
        [MakerNote] => Nikon
        [UserComment] =>                                                                                                                        
        [FlashPixVersion] => 0100
        [ColorSpace] => 1
        [ExifImageWidth] => 4896
        [ExifImageLength] => 3672
        [InteroperabilityOffset] => 1114
        [FileSource] => 
        [SceneType] => 
        [CustomRendered] => 0
        [ExposureMode] => 0
        [WhiteBalance] => 0
        [DigitalZoomRatio] => 0/100
        [FocalLengthIn35mmFilm] => 200
        [SceneCaptureType] => 0
        [GainControl] => 0
        [Contrast] => 0
        [Saturation] => 0
        [Sharpness] => 0
        [SubjectDistanceRange] => 0
        [GPSVersion] => 
        [InterOperabilityIndex] => R98
        [InterOperabilityVersion] => 0100
    )

    As for your question about print_r(), see the manual

  5. For the function to create a new file, the original image must have an orientation value and that value must be something other than 1. If it is 3, 6, or 8 it is rotated.

  6. 9 minutes ago, phppup said:

    So how come I am getting no result and you have success? What an I missing?

    I'll have to pass on that. Did the output of your original's exif data contain the "Orientation" value?

    In my test, the original had an orientation = 8. Here's the before and after

    <img src="images/DSCN0035.JPG" width="500"  >
    <img src="images/RDSCN0035.JPG" height="500" >      <!-- rotated version -->

    Results

    image.png.fd41e0475494df4aadd669b5fe003b4e.png

  7. 29 minutes ago, phppup said:

    Does the new image then contain EXIF info that head been adjusted to reflect the new orientation?

    I tried your function then pulled the exif data from the rotated image. Virtually all of the mass of data from the original has gone, including the "Orientation". Width and height were updated OK.''

    Exif from new image

    Array
    (
        [FileName] => RDSCN0035.JPG
        [FileDateTime] => 1575484231
        [FileSize] => 3509919
        [FileType] => 2
        [MimeType] => image/jpeg
        [SectionsFound] => COMMENT
        [COMPUTED] => Array
            (
                [html] => width="3672" height="4896"
                [Height] => 4896
                [Width] => 3672
                [IsColor] => 1
            )
    
        [COMMENT] => Array
            (
                [0] => CREATOR: gd-jpeg v1.0 (using IJG JPEG v90), quality = 95
    
            )
    
    )

     

  8. 10 minutes ago, SaranacLake said:

    Is there an easy way to leverage the array that I created - which contains a listing of all file-names from my photo directory - and somehow use HTML/PHP to navigate forward/backward one photo?

    Some complex maths is required.

    The array has an index, so if you are currently on the Nth element, subtract 1 to get the previous item or add 1 to get the next

    $current = $files[$n];
    $previous = $files[$n-1];
    $next = $files[$n+1];

     

  9. 12 hours ago, SaranacLake said:

    Yeah, that is on to-do list putting this site together!

    Christmas has come early!

    <?php
    const IMGDIR = 'images/';
    const THUMBDIR = 'thumbs/';
    const THUMBSIZE = 150;                                        // max thumbnail dimension
    const NUM = 100;                                              // number of images to be processed on each run
    
    $images = glob(IMGDIR.'{*.png,*.jpg}', GLOB_BRACE);
    $thumbs = glob(THUMBDIR.'{*.png,*.jpg}', GLOB_BRACE);
    // reduce to basenames only
    $images = array_map('basename', $images);
    $thumbs = array_map('basename', $thumbs);
    
    // copy the next NUM images to $todo list where thumbnails do not yet exist
    $todo = array_slice(array_diff($images, $thumbs), 0, NUM);
    
    $output = '';
    foreach ($todo as $fn) {
        $sz = getimagesize(IMGDIR.$fn);
        if ($sz[0] == 0) continue;                                // not an image
        $ok = 0;
        $out = null;
        switch ($sz['mime']) {                                    // check the mime types
            case 'image/jpeg':
                $im = imagecreatefromjpeg(IMGDIR.$fn);
                $ok = $im;
                $out = 'imagejpeg';
                break;
            case 'image/png':
                $im = imagecreatefrompng(IMGDIR.$fn);
                $ok = $im;
                $out = 'imagepng';
                break;
            default:
                $ok = 0;
        }
        if (!$ok) continue;                                       // not png or jpg
        
        // calculate thumbnail dimensions
        if ($sz[0] >= $sz[1]) {                                   // landscape
            $w = THUMBSIZE;
            $h = THUMBSIZE *  $sz[1]/$sz[0];
        } else {                                                  // portrait
            $h = THUMBSIZE;
            $w = THUMBSIZE * $sz[0]/$sz[1];
        }
        // copy and resize the image
        $tim = imagecreatetruecolor(THUMBSIZE, THUMBSIZE);
        $bg = imagecolorallocatealpha($tim,0xFF,0xFF,0xFF,127);
        imagefill($tim, 0, 0, $bg);
        imagecolortransparent($tim, $bg);
        // centre the image in the 150 pixel square
        $dx = (THUMBSIZE - $w) / 2;
        $dy = (THUMBSIZE - $h) / 2;
        imagecopyresized($tim, $im, $dx, $dy, 0, 0, $w, $h, $sz[0], $sz[1]);
        imagesavealpha($tim, true);
        
        $out($tim, THUMBDIR.$fn);
        imagedestroy($im);
        imagedestroy($tim);
        $output .= "<img src='".THUMBDIR."$fn' alt='$fn'>\n";
    }
    
    ?>
    <!DOCTYPE html>                   
    <html>
    <head>
    <meta http-equiv="content-language" content="en">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Create Thumbnails</title>
    <meta name="author" content="Barry Andrew">
    <meta name="creation-date" content="10/09/2019">
    <style type="text/css">
        body   { font-family: verdana, sans-serif; font-size: 11pt; }
        header { background-color: black; color: white; padding: 15px 10px;}
        img    { margin: 5px; }
     </style>
    </head>
    <body>
        <header>
            <h1>New Thumbnail Images</h1>
        </header>
        <?=$output?>
    </body>
    </html>

     

    • Like 2
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.