我现在已经在这里待了大约4个小时了。我已经尝试了几个我会在问题后解释的事情。
我从JPG中获得了所有这些EXIF数据(如下所列)
我要做的是将JPG重新保存到具有新名称的其他文件夹中。剥离“GCM_TAG”后,该新名称应该是$ data [“EXIF”] [“UserComment”]。这是在拍摄照片之前在仓库扫描的条形码。
我没有收到任何错误,我没有收到任何警告,但图像从未显示出来。如果我将代码更改为不包含$ barcode,则突然显示图像。我试过打印$ barcode,我试过检查变量的编码是什么,我试过使用fopen(),file_put_contents()和copy()都无济于事。每个人都有相同的结果。该文件夹有777权限,我可以使用PHP添加/删除文件就好了,并在此代码中测试了。任何帮助将不胜感激。
chdir("../test_import_photos");
$directory = getcwd();
echo __FILE__;
print "<br />";
print $directory;
if ($dirhandle = opendir($directory))
{
while (false !== ($entry = readdir($dirhandle)))
{
if($entry == "." || $entry == "..")
{
//ignore, its just the folder commands
}
else
{
$data = exif_read_data($entry,"ANY_TAG",true,false);
//print "2";
//print "3";
$barcode = str_replace("GCM_TAG","",$data["EXIF"]["UserComment"]);
$filepath = "../test_import_photos_end/X" . $barcode . ".JPG";
copy($entry, $filepath);
}
}
closedir($dirhandle);
}
Array(
[FILE] => Array
(
[FileName] => RIMG0089.JPG
[FileDateTime] => 1385421951
[FileSize] => 2592157
[FileType] => 2
[MimeType] => image/jpeg
[SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF, INTEROP
)
[COMPUTED] => Array
(
[html] => width="4000" height="3000"
[Height] => 3000
[Width] => 4000
[IsColor] => 1
[ByteOrderMotorola] => 1
[ApertureFNumber] => f/3.5
[UserComment] => GCM_TAG
[UserCommentEncoding] => UNDEFINED
[Copyright] =>
[Thumbnail.FileType] => 2
[Thumbnail.MimeType] => image/jpeg
)
[IFD0] => Array
(
[ImageDescription] => Exif_JPEG_PICTURE
[Make] => RICOH
[Model] => G700 SE
[Orientation] => 1
[XResolution] => 72/1
[YResolution] => 72/1
[ResolutionUnit] => 2
[Software] => G700SE Firmware
[DateTime] => 2013:11:25 02:53:04
[YCbCrPositioning] => 2
[Copyright] =>
[Exif_IFD_Pointer] => 552
[UndefinedTag:0xC4A5] => PrintIM0300d
''''''''''''''''' )
[THUMBNAIL] => Array
(
[Compression] => 6
[XResolution] => 72/1
[YResolution] => 72/1
[ResolutionUnit] => 2
[JPEGInterchangeFormat] => 12276
[JPEGInterchangeFormatLength] => 2724
)
[EXIF] => Array
(
[ExposureTime] => 1/30
[FNumber] => 350/100
[ExposureProgram] => 2
[ISOSpeedRatings] => 320
[ExifVersion] => 0221
[DateTimeOriginal] => 2013:11:25 02:53:04
[DateTimeDigitized] => 2013:11:25 02:53:04
[ComponentsConfiguration] =>
[CompressedBitsPerPixel] => 184/100
[ApertureValue] => 35/100
[BrightnessValue] => 200/100
[ExposureBiasValue] => 0/100
[MaxApertureValue] => 361/100
[MeteringMode] => 5
[LightSource] => 0
[Flash] => 16
[FocalLength] => 500/100
[MakerNote] => Ricoh
Rdchp &lt;
Revv1.2ve
v1.29#b6#@EYEHFFA00!
^ h的R&amp!; jjKT0
r LAt@ $z fR 5 E 5*我@#$E +C W 6 J ^֑
n,$$$HFD 5Qu!C
^ A + x .Bu r&gt; 2=:&lt;7736.Bu r&gt;
ioyr
!'$,/ $“# *安培; + 0 ./(+%&安培; $ %% - 39&LT ;;将N&LT ;; / 5qBdddNJ :\ EE E 1,'P = RO“EEEEY @ R%0%0% - :P)` jdpq Q V 6E6E6E
[UserComment] => GCM_TAG11800038
[FlashPixVersion] => 0100
[ColorSpace] => 1
[ExifImageWidth] => 4000
[ExifImageLength] => 3000
[InteroperabilityOffset] => 1732
[ExposureMode] => 0
[WhiteBalance] => 0
[SceneCaptureType] => 0
[Sharpness] => 0
)
[INTEROP] => Array
(
[InterOperabilityIndex] => R98
[InterOperabilityVersion] => 0100
)
)
答案 0 :(得分:0)
我看到文件名出错(二进制数据可能会破坏数组())而copy()只会抛出一条E_WARNING消息,必须添加到error_reporting(E_ALL);或error_reporting(E_WARNING);看到它。