Comment puis-je accéder et modifier la propriété de description de tag d’une image JPEG dans l’explorateur de fichiers Windows 7 en utilisant Python?

J’ai du mal à comprendre comment je peux changer les balises d’un fichier JPEG via Python. Les “balises” auxquelles je fais référence sont celles sous les propriétés de description de tout fichier arbitraire, où les commentaires, les sujets et les classements seraient également trouvés. Je ne suis pas sûr qu’il y ait ou non une fonction .os similaire à la fonction renommer le nom de fichier qui peut le faire, ou si ce type d’opération de modification des balises relève de la catégorie de manipulation JPEG Metadata / EXIFDATA.

Disons, par exemple, que je veux append 3 balises à une image JPEG via Python, celles-ci étant les balises BLUE, SQUARE et 9. Manuellement, j’irais au fichier, accéder aux propriétés de la description soit en cliquant avec le bouton droit sur le fichier à afficher. ses balises, ou en cliquant sur le menu de la barre inférieure, et cliquez sur les balises pour ensuite entrer BLUE, SQUARE et 9 dans la zone de texte, avec un point-virgule après chaque balise individuelle. Avec Python, j’aurais besoin d’un script capable d’injecter ces balises individuelles dans les propriétés de description du JPEG pour rendre le processus moins pénible si je le faisais de manière itérative pour plusieurs fichiers JPEG.

Je doute que cela nécessite une connaissance sévère de la programmation avec Python, mais en même temps la spécificité de mon problème semble échapper à une résolution facile. Je ne peux pas sembler trouver une réponse semi-claire ou simple, car je suis un peu un verteur quand il s’agit de programmer avec python en général.

Toute aide serait très, très utile. J’utilise Python 3.5.2. au fait.

Alors, voici ma réponse révisée. Donc, toutes les informations dans un jpg sont des métadonnées stockées avec un numéro “id”, par exemple, 0 est la zone de description que vous recherchez pour une table.

0th: 283 = (720000, 10000) 296 = 2 34665 = 11444 306 = b'2011:08:22 21:39:05' 270 = b'' 271 = b'OLYMPUS IMAGING CORP.' 272 = b'E-P1' 305 = b'Adobe Photoshop CS5 Windows' 274 = 1 33432 = b'Robin Parmar' 282 = (720000, 10000) 315 = b'Robin Parmar' 

source http://www.theatreofnoise.com/2016/10/how-to-resortingeve-photo-metadata-in-python.html

Donc, pour changer comme le sujet, il suffit de …

 pip install piexif 

Cela fonctionne avec 2.7 et 3

 import piexif def insert_sample(): zeroth_ifd = {270: "test"} exif_bytes = piexif.dump({"0th":zeroth_ifd}) piexif.insert(exif_bytes,'img.jpg') insert_sample() 

J’espère que cela aide: D Hé une liste de tous les identifiants

 << Inspect piexif >> 11 = ProcessingSoftware 18246 = Rating 18249 = RatingPercent 254 = NewSubfileType 255 = SubfileType 256 = ImageWidth 257 = ImageLength 258 = BitsPerSample 259 = Compression 262 = PhotomesortingcInterpretation 263 = Threshholding 264 = CellWidth 265 = CellLength 266 = FillOrder 269 = DocumentName 270 = ImageDescription 271 = Make 272 = Model 273 = SsortingpOffsets 274 = Orientation 277 = SamplesPerPixel 278 = RowsPerSsortingp 279 = SsortingpByteCounts 282 = XResolution 283 = YResolution 284 = PlanarConfiguration 290 = GrayResponseUnit 291 = GrayResponseCurve 292 = T4Options 293 = T6Options 296 = ResolutionUnit 301 = TransferFunction 305 = Software 306 = DateTime 315 = Artist 316 = HostComputer 317 = Predictor 318 = WhitePoint 319 = PrimaryChromaticities 320 = ColorMap 321 = HalftoneHints 322 = TileWidth 323 = TileLength 324 = TileOffsets 325 = TileByteCounts 32781 = ImageID 330 = SubIFDs 332 = InkSet 333 = InkNames 334 = NumberOfInks 33421 = CFARepeatPatternDim 33422 = CFAPattern 33423 = BatteryLevel 33432 = Copyright 33434 = ExposureTime 336 = DotRange 337 = TargetPrinter 338 = ExtraSamples 339 = SampleFormat 340 = SMinSampleValue 341 = SMaxSampleValue 342 = TransferRange 343 = ClipPath 34377 = ImageResources 344 = XClipPathUnits 345 = YClipPathUnits 346 = Indexed 34665 = ExifTag 34675 = InterColorProfile 347 = JPEGTables 34853 = GPSTag 34857 = Interlace 34858 = TimeZoneOffset 34859 = SelfTimerMode 351 = OPIProxy 37387 = FlashEnergy 37388 = SpatialFrequencyResponse 37389 = Noise 37390 = FocalPlaneXResolution 37391 = FocalPlaneYResolution 37392 = FocalPlaneResolutionUnit 37393 = ImageNumber 37394 = SecurityClassification 37395 = ImageHistory 37397 = ExposureIndex 37398 = TIFFEPStandardID 37399 = SensingMethod 40091 = XPTitle 40092 = XPComment 40093 = XPAuthor 40094 = XPKeywords 40095 = XPSubject 50341 = PrintImageMatching 50706 = DNGVersion 50707 = DNGBackwardVersion 50708 = UniqueCameraModel 50709 = LocalizedCameraModel 50710 = CFAPlaneColor 50711 = CFALayout 50712 = LinearizationTable 50713 = BlackLevelRepeatDim 50714 = BlackLevel 50715 = BlackLevelDeltaH 50716 = BlackLevelDeltaV 50717 = WhiteLevel 50718 = DefaultScale 50719 = DefaultCropOrigin 50720 = DefaultCropSize 50721 = ColorMasortingx1 50722 = ColorMasortingx2 50723 = CameraCalibration1 50724 = CameraCalibration2 50725 = ReductionMasortingx1 50726 = ReductionMasortingx2 50727 = AnalogBalance 50728 = AsShotNeutral 50729 = AsShotWhiteXY 50730 = BaselineExposure 50731 = BaselineNoise 50732 = BaselineSharpness 50733 = BayerGreenSplit 50734 = LinearResponseLimit 50735 = CameraSerialNumber 50736 = LensInfo 50737 = ChromaBlurRadius 50738 = AntiAliasStrength 50739 = ShadowScale 50740 = DNGPrivateData 50741 = MakerNoteSafety 50778 = CalibrationIlluminant1 50779 = CalibrationIlluminant2 50780 = BestQualityScale 50781 = RawDataUniqueID 50827 = OriginalRawFileName 50828 = OriginalRawFileData 50829 = ActiveArea 50830 = MaskedAreas 50831 = AsShotICCProfile 50832 = AsShotPreProfileMasortingx 50833 = CurrentICCProfile 50834 = CurrentPreProfileMasortingx 50879 = ColorimesortingcReference 50931 = CameraCalibrationSignature 50932 = ProfileCalibrationSignature 50934 = AsShotProfileName 50935 = NoiseReductionApplied 50936 = ProfileName 50937 = ProfileHueSatMapDims 50938 = ProfileHueSatMapData1 50939 = ProfileHueSatMapData2 50940 = ProfileToneCurve 50941 = ProfileEmbedPolicy 50942 = ProfileCopyright 50964 = ForwardMasortingx1 50965 = ForwardMasortingx2 50966 = PreviewApplicationName 50967 = PreviewApplicationVersion 50968 = PreviewSettingsName 50969 = PreviewSettingsDigest 50970 = PreviewColorSpace 50971 = PreviewDateTime 50972 = RawImageDigest 50973 = OriginalRawFileDigest 50974 = SubTileBlockSize 50975 = RowInterleaveFactor 50981 = ProfileLookTableDims 50982 = ProfileLookTableData 51008 = OpcodeList1 51009 = OpcodeList2 51022 = OpcodeList3 51041 = NoiseProfile 512 = JPEGProc 513 = JPEGInterchangeFormat 514 = JPEGInterchangeFormatLength 515 = JPEGRestartInterval 517 = JPEGLosslessPredictors 518 = JPEGPointTransforms 519 = JPEGQTables 520 = JPEGDCTables 521 = JPEGACTables 529 = YCbCrCoefficients 530 = YCbCrSubSampling 531 = YCbCrPositioning 532 = ReferenceBlackWhite 60606 = ZZZTestSlong1 60607 = ZZZTestSlong2 700 = XMLPacket