<small id='0C5tT'></small><noframes id='0C5tT'>

      • <bdo id='0C5tT'></bdo><ul id='0C5tT'></ul>

        <i id='0C5tT'><tr id='0C5tT'><dt id='0C5tT'><q id='0C5tT'><span id='0C5tT'><b id='0C5tT'><form id='0C5tT'><ins id='0C5tT'></ins><ul id='0C5tT'></ul><sub id='0C5tT'></sub></form><legend id='0C5tT'></legend><bdo id='0C5tT'><pre id='0C5tT'><center id='0C5tT'></center></pre></bdo></b><th id='0C5tT'></th></span></q></dt></tr></i><div id='0C5tT'><tfoot id='0C5tT'></tfoot><dl id='0C5tT'><fieldset id='0C5tT'></fieldset></dl></div>
        <legend id='0C5tT'><style id='0C5tT'><dir id='0C5tT'><q id='0C5tT'></q></dir></style></legend>

        <tfoot id='0C5tT'></tfoot>

        图片在上传时自动旋转

        Image getting rotated automatically on upload(图片在上传时自动旋转)
          <tbody id='CeHLN'></tbody>
        • <bdo id='CeHLN'></bdo><ul id='CeHLN'></ul>

              <small id='CeHLN'></small><noframes id='CeHLN'>

            • <i id='CeHLN'><tr id='CeHLN'><dt id='CeHLN'><q id='CeHLN'><span id='CeHLN'><b id='CeHLN'><form id='CeHLN'><ins id='CeHLN'></ins><ul id='CeHLN'></ul><sub id='CeHLN'></sub></form><legend id='CeHLN'></legend><bdo id='CeHLN'><pre id='CeHLN'><center id='CeHLN'></center></pre></bdo></b><th id='CeHLN'></th></span></q></dt></tr></i><div id='CeHLN'><tfoot id='CeHLN'></tfoot><dl id='CeHLN'><fieldset id='CeHLN'></fieldset></dl></div>
              • <tfoot id='CeHLN'></tfoot>
              • <legend id='CeHLN'><style id='CeHLN'><dir id='CeHLN'><q id='CeHLN'></q></dir></style></legend>

                  本文介绍了图片在上传时自动旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试上传 base64 编码图像并在解码后保存.图片正在上传和保存,我可以使用 URL 和所有内容访问它..但是图片逆时针旋转了 90 度,我不知道为什么!!

                  I'm trying to upload a base64 encoded image and save after decoding it. Image is getting uploaded and saved, and I can access it using a URL and everything..but the image gets rotated by 90 degrees anti-clockwise and I have no idea WHY!!

                  我得到编码数据的地方很好,因为把它放在 <img/> 工作正常!

                  The place where I get the encoded data is fine, as putting it in <img /> works fine!

                  function saveImageData($base64Data) {
                      $base64_decoded = base64_decode($base64Data);
                      $im = imagecreatefromstring($base64_decoded);
                      if ($im !== false) {
                          $imagepath = '/public/uploads/' . time() . '.jpg';
                          imagejpeg($im, $imagepath);
                          chmod($imagepath, 0755);
                          imagedestroy($im);
                      } else {
                          return false;
                      }
                      return $imagepath;
                  }
                  

                  我没有使用任何旋转功能,但它仍然在旋转.我可以使用像 imagerotate 这样的 PHP GD 函数,但不想因为黑色背景等原因.

                  I'm not using any rotation functions, but still its getting rotated. I can use a PHP GD function like imagerotate, but don't want to for reasons like black backgrounds etc.

                  如果你能帮上忙……你是最棒的人!!

                  If you can help..you r the awesomest person!!

                  推荐答案

                  我的猜测是您上传的图像实际上是旋转的,但正在被纠正,因为它的 EXIF 部分包含旋转数据.(例如,相机在拍照时可能会感知纵向,并将该信息保存在 EXIF 数据中;某些查看软件会感知旋转数据,并在查看照片时会自动旋转照片.)在这种情况下,图像可能只是出现为您旋转,具体取决于您用于查看它的内容.

                  My guess would be that the image you're uploading is actually rotated, but is being corrected because it contains rotation data in its EXIF section. (For example, a camera may be aware of portrait orientation when taking a photo, and save that information in the EXIF data; some viewing software is aware of the rotation data and will auto-rotate the photo when viewing it.) In which case, the image might just be appearing to be rotated for you, depending on what you're using to view it.

                  您是否使用同一软件查看上传前"和上传后"图像?例如,如果您使用相同的网络浏览器查看它们会发生什么?

                  Are you viewing the "before upload" and "after upload" images using the same software? What happens if you look at them both using the same web browser, say?

                  如果您尝试不同的图片,最好是来自不同来源的图片,会发生什么情况?你有任何软件可以让你查看图像的 EXIF 数据吗?寻找方向"值;1"以外的任何内容都表示为图像设置了旋转(请参阅 此页面 以获得体面的描述.)

                  What happens if you try a different image, preferably from a different source? Do you have any software that will allow you to view the image's EXIF data? Look for the "Orientation" value; anything other than "1" means there's a rotation set for the image (see this page for a decent description.)

                  因此,总而言之,我会说 JPEG 文件中的底层图像处于错误"方向,并且 EXIF 数据包含用于纠正显示旋转的信息.如果源是,例如,刚刚玩过我的 iPhone,这很可能会以横向存储其底层图像数据,但如果图像是实际拍摄的,则设置 EXIF 数据(因此应该显示) 作为肖像.

                  So, in summary, I'd say that that the underlying image in the JPEG file is at the "wrong" orientation, and the EXIF data contains information to correct that rotation for display. This is very likely if the source is, for example, an iPhone, which having just played with mine, seems to store its underlying image data in landscape orientation, but set the EXIF data if the image was actually taken (and should therefore be displayed) as portrait.

                  修复它的最佳方法几乎肯定是在上传后检查文件上的 EXIF 数据,使用 PHP EXIF 函数 并根据需要旋转图像以纠正方向,然后再保存您自己的副本.

                  Best way to fix it is almost certainly to examine the EXIF data on the file after upload, using the PHP EXIF functions and rotate the image as necessary to correct the orientation before saving your own copy.

                  这篇关于图片在上传时自动旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  When should use doctrine ORM and when zend-db-table?(什么时候应该使用学说 ORM,什么时候应该使用 zend-db-table?)
                  Doctrine - self-referencing entity - disable fetching of children(Doctrine - 自引用实体 - 禁用获取子项)
                  Doctrine 2, query inside entities(原则 2,实体内部查询)
                  Complex WHERE clauses using the PHP Doctrine ORM(使用 PHP Doctrine ORM 的复杂 WHERE 子句)
                  Doctrine - OneToMany relation, all result row doesn#39;t fetch in object(Doctrine - OneToMany 关系,所有结果行不获取对象)
                  Doctrine and unrefreshed relationships(教义和未更新的关系)
                    <tbody id='efYVr'></tbody>
                  <tfoot id='efYVr'></tfoot>

                  <small id='efYVr'></small><noframes id='efYVr'>

                  • <legend id='efYVr'><style id='efYVr'><dir id='efYVr'><q id='efYVr'></q></dir></style></legend>
                    • <bdo id='efYVr'></bdo><ul id='efYVr'></ul>

                      1. <i id='efYVr'><tr id='efYVr'><dt id='efYVr'><q id='efYVr'><span id='efYVr'><b id='efYVr'><form id='efYVr'><ins id='efYVr'></ins><ul id='efYVr'></ul><sub id='efYVr'></sub></form><legend id='efYVr'></legend><bdo id='efYVr'><pre id='efYVr'><center id='efYVr'></center></pre></bdo></b><th id='efYVr'></th></span></q></dt></tr></i><div id='efYVr'><tfoot id='efYVr'></tfoot><dl id='efYVr'><fieldset id='efYVr'></fieldset></dl></div>