PHP图片库-处理iPhone/iPad图片
我用 php 和 mysql 创建了一个图像库,结合了多种添加图像和图像的方法。能够按添加方法和/或类别进行排序。在注意到苹果设备中的一些图像显示“错误”方向后,我创建了另一个页面来编辑方向和其他文件信息,然后将所述更改保存回文件和数据库。只有在我认为我已经解决了这个问题之后,我才在苹果设备上查看更改后的图像,才意识到图像现在在所述设备上处于“错误”方向。我一直在谷歌上搜索这个,但不太清楚我现在需要学习什么来处理这种情况下来自苹果设备的图像。如果能朝正确的方向推动,我们将不胜感激。
谢谢!
Ive created an image gallery with php and mysql, incorporating several ways to add images & ability to sort by addition method and/or category. After noticing some images from apple devices showed up with the 'wrong' orientation, I created another page to edit orientation and other file info, then save said changes back to file and db. Only after I thought I had solved this problem did I view the altered images on an apple device, only to realize that image was now in 'wrong' orientation on said device. I've been googling this, but can't quite figure out exactly what I need to learn now to deal with images from apple devices in this situation. A shove in the right direction would be greatly appreciated.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在我的“gallery3”照片库中看到同样的问题。与 machouinard 一样,我使用“jhead -norot filename.jpg”从图像中去除方向标题。这解决了 Apple 的旋转问题,并且似乎不会扰乱其他浏览器。
要编辑一堆文件,我直接进入 (gallerytop)/lib/albums 中的相册存储区域并执行
find -type f | xargs sudo jhead -norot
。它足够聪明,只修改需要修改的文件,并且在工作时将它们的列表打印到标准输出。为了让 gallery3 更新缩略图,我进入数据库并设置“脏”标志,如下所示:
echo "update items setthumb_dirty=1,resize_dirty=1 whererelative_path_cache like 'ALBUMNAME/%';" | mysql -u root -p gallery3 。然后我进入图库维护模式并运行“重建图像”实用程序。
Seeing the same problem on my "gallery3" photo gallery. Like machouinard, I am using "jhead -norot filename.jpg" to strip the orientation header from the images. This fixes the Apple rotation problem, and it does not seem to mess up the other browsers.
To edit a bunch of the files in place, I go directly to the album storage area in (gallerytop)/lib/albums and do
find -type f | xargs sudo jhead -norot
. It is smart enough to only modify the files that need to be modified, and it'll print out a list of them to stdout as it is working.To get gallery3 to update the thumbnails, I go into the database and set the "dirty" flags like this:
echo "update items set thumb_dirty=1,resize_dirty=1 where relative_path_cache like 'ALBUMNAME/%';" | mysql -u root -p gallery3
. Then I go into the gallery maintenance mode and run the "rebuild images" utility.忘记我发过这个了。我想出了如何处理方向问题,所以我想我会分享。现在看来很简单。此后我使用 Codeigniter 重新创建了这个项目。 CI 很棒,可以节省很多时间,但我很高兴我第一次自己编写了它。我确实通过这种方式学到了更多。
首先,如果文件是 jpg,我会使用 PEL 获取 EXIF 数据。
$new
是要检查方向的上传文件。然后,如果 EXIF 存在,则获取方向值并通过 switch 语句运行它,相应地旋转它,然后重置方向值。我正在使用 image_moo 和 Codeigniter,但这显然可以更改为使用任何图像处理库。
老实说,我不确定是否所有这些 IF 语句都需要在那里,但我一直遇到只包含一些 EXIF 信息的 jpg 的麻烦,如果没有它们,脚本就会崩溃。
希望这对遇到同样问题的其他人有所帮助。
如果您发现任何可以改进的地方,请告诉我。但这对我来说非常有用。
标记
Forgot I posted this. I figured out how to handle the orientation issue so I thought I'd share. Seems simple now. I've since recreated this project using Codeigniter. CI is great and saves a lot of time, but I'm glad I wrote it all myself the first time. I sure learned more that way.
First, if the file is a jpg, I get the EXIF data with PEL .
$new
is the uploaded file to be checked for orientation.Then if EXIF exists, get the orientation value and run it through a switch statement, rotate it accordingly and then reset the orientation value. I'm using image_moo and Codeigniter, but this can obviously be changed to use any image manipulation library.
I'm honestly not sure if all those IF statements need to be there, but I kept running into trouble with jpg's that only included some EXIF info and would blow up the script without them.
Hope this will be helpful to someone else struggling with the same issues.
If you see anything that could be improved, please let me know. But this works great for me.
Mark