GoingElectric

Anzeigeproblem hochgeladene Bilder gedreht

9 Beiträge

Anzeigeproblem hochgeladene Bilder gedreht

Ahvi5aiv
25.05.2015 22:40
Hallo,

ich habe das Problem das mit meinem Handy geschossene Fotos zwar auf dem Handy und dem Computer korrekt angezeigt werden, dann aber nach dem hochladen und einfügen in einen Thread entweder gekippt oder kopf stehend angezeigt werden.

Beispiel: http://www.goingelectric.de/forum/nissa ... ml#p205414

Korrekt sollten die Bilder so aussehen:
alle.png
Liegt das nur an meinem Browser (Firefox 31.7.0) und gibt es jemand bei dem die Bilder korrekt angezeigt werden?
Es scheint ja damit zusammen zu hängen, das die Bilder mit Ausrichtungsmerkmal erstellt wurden.
Anzeige

Re: Anzeigeproblem hochgeladene Bilder gedreht

Toumal
25.05.2015 22:54
Ja anscheinend parst das Forum nicht die orientation info aus dem EXIF.

Simpler fix: http://www.sanwebe.com/2012/05/fix-imag ... -exif-data

Re: Anzeigeproblem hochgeladene Bilder gedreht

Zoelibat
25.05.2015 23:06
Ist mir gerade auch wieder aufgefallen bei der Bestätigung eines Bildes im VZ. Passiert hin und wieder, denke das kann wirklich mit dem Upload per Handy zu tun haben.

Re: Anzeigeproblem hochgeladene Bilder gedreht

Ahvi5aiv
25.05.2015 23:44
Toumal hat geschrieben:Simpler fix: http://www.sanwebe.com/2012/05/fix-imag ... -exif-data
Müsste dann aber sicherlich in der Forensoftware behoben werden...?

Re: Anzeigeproblem hochgeladene Bilder gedreht

Ahvi5aiv
25.05.2015 23:54
Hi, habe auch noch was gefunden:

https://www.phpbb.com/community/viewtop ... &t=2171923 weiter unten nach der Diskussion ob nicht die User einfach mal die Kamera richtig halten sollten, haha oder einfach das Foto im Desktop editieren sollten (noch ein ).
Da lob ich mal den User der einen Fix bereit gestellt hat:

Code: Alles auswählen

Postby jcocking » Sat Feb 16, 2013 9:04 pm
I got bored and wrote the modification myself. I have attached the code here for your use if you are looking for the same modification.

No Warranty. No Support. Use at your own Risk. Backup Everything.

This code snippets does the following.
1. It will resize large files. The code will look at the width/height and compare to default setting defined in the function ImageResizeAndOrient(). You can change the defaults within the code.
2. The resize will work on gif, jpg and png files. The resulting saved file is a jpg.
3. If the file is a jpg, the code will look at the exif data and change the orientation of the picture to be positioned correctly. The save removes the EXIF to keep the picture correctly.

Files to Edit:

    includes/functions_upload.php


Edits:

    Find:

    Code: Select all
       /**
       * Performing additional checks

    Before Add:

    Code: Select all
      //Added new image functions
      /**
      *   ImageHandler - ImageResizeAndOrient()
       *   Function will resize images and correct orientation
      *
      */
      function ImageResizeAndOrient()
      {
          // Edit values to control functionality
        $max_width = 1200;
        $max_height = 1000;
        // No need to edit beyond this point
          
         //get the image size
          $destinationImage = false;
         $size = getimagesize($this->destination_file);
         //determine dimensions
         $width = $size[0];
         $height = $size[1];
         if ($width > $max_width || $height > $max_height) {
             ini_set("memory_limit","128M");
            //determine what the file extension of the source
           switch($this->extension)
           {
              case 'gif': case 'GIF':
                 $sourceImage = imagecreatefromgif($this->destination_file);
                 break;
              case 'jpg': case 'JPG': case 'jpeg':
                 $sourceImage = imagecreatefromjpeg($this->destination_file);
                 break;
              case 'png': case 'PNG':
                 $sourceImage = imagecreatefrompng($this->destination_file);
                 break;
           }
           // find the largest dimension of the image
           // then calculate the resize perc based upon that dimension
           $percentage = ( $width >= $height ) ? $max_width/$width : $max_height/$height;
           // define new width / height
           $newWidth = round($width * $percentage);
           $newHeight = round($height * $percentage);
           // create a new image
           $destinationImage = imagecreatetruecolor($newWidth, $newHeight);
           // copy resampled
           imagecopyresampled($destinationImage, $sourceImage, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
          }
          if ($this->extension == "jpg" || $this->extension == "jpeg") {
              $flip=$rotate=false;
             if (!$destinationImage) $destinationImage = imagecreatefromjpeg($this->destination_file);
          //evaluate exif data from photo
          $exif = exif_read_data($this->destination_file);
          //get the orientation
          $ort = $exif['Orientation'];
          //determine what oreientation the image was taken at
          switch($ort)
          {
              case 2: // horizontal flip
                         $flip = true;
                  break;
              case 3: // 180 rotate left
                         $rotate = 180;
                  break;
              case 4: // vertical flip
                         $flip = true;
                         $rotate = 180;
                  break;
              case 5: // vertical flip + 90 rotate right
                         $flip = true;
                         $rotate = 90;
                  break;
              case 6: // 90 rotate right
                         $rotate = -90;
                  break;
              case 7: // horizontal flip + 90 rotate right
                         $flip = true;
                         $rotate = -90;                     
                  break;
              case 8: // 90 rotate left
                         $rotate = 90;
                  break;
          }
          // create the jpegs
           if ($flip) $this->ImageFlip($destinationImage);   
           if ($rotate) $destinationImage = imagerotate($destinationImage, $rotate, -1);
        }
         if ($destinationImage) {
              imagejpeg($destinationImage, $this->destination_file, 100);
              $this->extension = "jpg";
              return;
         } else {
            return;
         }      
      }
     
      /**
      *   ImageHandler - ImageFlip()
      *
      */
      function ImageFlip(&$image, $x = 0, $y = 0, $width = null, $height = null)
      {
       
          if ($width  < 1) $width  = imagesx($image);
          if ($height < 1) $height = imagesy($image);
       
          // Truecolor provides better results, if possible.
          if (function_exists('imageistruecolor') && imageistruecolor($image))
          {
              $tmp = imagecreatetruecolor(1, $height);
          } else {
              $tmp = imagecreate(1, $height);
          }
     
          $x2 = $x + $width - 1;
     
          for ($i = (int)floor(($width - 1) / 2); $i >= 0; $i--)
          {
              // Backup right stripe.
              imagecopy($tmp, $image, 0, 0, $x2 - $i, $y, 1, $height);
     
              // Copy left stripe to the right.
              imagecopy($image, $image, $x2 - $i, $y, $x + $i, $y, 1, $height);
     
              // Copy backuped right stripe to the left.
              imagecopy($image, $tmp, $x + $i,  $y, 0, 0, 1, $height);
          }
     
          imagedestroy($tmp);
     
          return true;
      }
    Find:

    Code: Select all
    phpbb_chmod($this->destination_file, $chmod);

    Before Add:

    Code: Select all
             // Check image orientation
             if ($this->is_image()) $this->ImageResizeAndOrient();
Vielleicht kann einer der Serveradmins das verwenden?

PS: Ich hoffe es gibt kein Problem damit mal kurzerhand den gefundenen Kram hier zu zitieren. Immerhin habe ich die Quelle angegeben
Anzeige

Re: Anzeigeproblem hochgeladene Bilder gedreht

climenole
26.05.2015 00:02
@Zoelibat: Du meinst nicht zufällig mein Foto in Essen? Ich habe das Problem nämlich gerade... Habe jetzt mehrfach in unterschiedlichen Programmen geöffnet und neu abgespeichert, überall ist die Anzeige korrekt, außer hier beim Upload. Bin ratlos, werde das Bild einfach nicht einstellen...
Zoe Intens 3/13 überführt aus dem Elsass seit Juli 2014 und seit August 2017 noch ne blaue Zoe Intens Q90
powered by 22kW von Naturstrom (http://www.naturstrom.de)

Re: Anzeigeproblem hochgeladene Bilder gedreht

Anonymous
26.05.2015 00:08
climenole hat geschrieben:@Zoelibat: Du meinst nicht zufällig mein Foto in Essen? Ich habe das Problem nämlich gerade... Habe jetzt mehrfach in unterschiedlichen Programmen geöffnet und neu abgespeichert, überall ist die Anzeige korrekt, außer hier beim Upload. Bin ratlos, werde das Bild einfach nicht einstellen...
Passiert mir ständig, speziell bei Handyaufnahmen ...

Lade das Bild mal mit GIMP ein.
Da wird entweder automatisch gedreht, bzw. nachgefragt, abspeichern ...
Enjoy

Beispiel aus Pfronten
20140722_210546.jpg
20140722_210546_0.jpg

Re: Anzeigeproblem hochgeladene Bilder gedreht

Zoelibat
26.05.2015 17:42
climenole hat geschrieben:@Zoelibat: Du meinst nicht zufällig mein Foto in Essen? Ich habe das Problem nämlich gerade... Habe jetzt mehrfach in unterschiedlichen Programmen geöffnet und neu abgespeichert, überall ist die Anzeige korrekt, außer hier beim Upload. Bin ratlos, werde das Bild einfach nicht einstellen...
Ja, richtig. Ich selber drehe meine Bilder im Windows-Bildbetrachter und bearbeite meine Fotos im Photoshop (Fotos der Kamera).

Gimp ist ganz ähnlich wie Photoshop, hat nur eine grauenhafte (ungewohnte?) Bedienung.

Re: Anzeigeproblem hochgeladene Bilder gedreht

Guy
28.05.2015 22:50
Im Verzeichnis nutze ich eine ähnliche Lösung, um die Fotos automatisch zu drehen. Das geht allerdings nur, wenn die Orientierung in der Fotodatei gespeichert ist.

Werde das die Tage einbauen.
Anzeige

Registrieren
Anmelden