ncdcdev / cordova-plugin-blackboard-camera

0 stars 0 forks source link

[TASK] J-COMSIA認定のためのExif情報追加 #30

Open karuru6225 opened 12 months ago

karuru6225 commented 12 months ago

タスク

J-COMSIA認定に合格するために、追加で必要なExifの追加をお願いします。

資料

karuru6225 commented 11 months ago

残りは // ComponentsConfiguration 各コンポーネントの意味 0x9101 Undefined 4 ◎ // FlashpixVersion 対応フラッシュピックスバージョン 0xA000 Undefined 4 ◎ の2つ。

JangSungChul commented 11 months ago

@karuru6225 https://github.com/ncdcdev/cordova-plugin-blackboard-camera/blob/a86fbadcd7ae06c42418b7413f566e13b29ab27f/src/ios/ElectronicBlackBoardManager.swift#L43-L44

こちらのことでしょうか? すみませんが、既存のコードの修正意図が分からずですが、↑はコメントですね? kCGImagePropertyExifDictionaryComponentsConfigurationFlashpixVersionの情報を入れる感じでしょうか?

https://github.com/ncdcdev/cordova-plugin-blackboard-camera/pull/29/commits/243c1a4eabff5cafa84e07750e4e8f443baea21d

karuru6225 commented 11 months ago

@JangSungChul そうですね。以下の2つだと思います。 https://developer.apple.com/documentation/imageio/kcgimagepropertyexifcomponentsconfiguration https://developer.apple.com/documentation/imageio/kcgimagepropertyexifflashpixversion

JangSungChul commented 8 months ago

問題:AndroidでXMP情報が2回入力される

https://github.com/ncdcdev/cordova-plugin-blackboard-camera/blob/a7516c4c831967614d0f66d36470a2c8a5613fa9/src/android/ElectronicBlackBoardManager.kt#L25-L29

photoInfo.toXMP()を出力

<x:xmpmeta
    xmlns:x="adobe:ns:meta/">
    <rdf:RDF
        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
        <rdf:Description rdf:about=""
            xmlns:photo="http://dcpadv.org/schema/3.0/photoinfo"
            xmlns:measurement="http://dcpadv.org/schema/3.0/measurement"
            xmlns:item="http://dcpadv.org/schema/3.0/measurementitem">
            <photo:ConstructionName>動作テストTBH221030</photo:ConstructionName>
            <photo:Contructor>大成建設(株)</photo:Contructor>
            <photo:LargeClassification>測量</photo:LargeClassification>
            <photo:PhotoClassification>施工状況写真</photo:PhotoClassification>
            <photo:ConstructionType>工種TBH221030</photo:ConstructionType>
            <photo:MiddleClassification>種別TBH221030</photo:MiddleClassification>
            <photo:SmallClassification>細別TBH221030</photo:SmallClassification>
            <photo:Title>A0. 鉄筋籠搬入状況</photo:Title>
            <photo:ClassificationRemarks>
                <rdf:Seq></rdf:Seq>
            </photo:ClassificationRemarks>
            <photo:ShootingSpot></photo:ShootingSpot>
            <photo:IsRepresentative>False</photo:IsRepresentative>
            <photo:IsFrequencyOfSubmission>True</photo:IsFrequencyOfSubmission>
            <photo:Measurements>
                <rdf:Description>
                    <measurement:Classification>0</measurement:Classification>
                    <measurement:MeasurementItems>
                        <rdf:Seq>
                            <rdf:li>
                                <rdf:Description>
                                    <item:Name>鉄筋籠搬入状況</item:Name>
                                    <item:Mark></item:Mark>
                                    <item:DesignedValue></item:DesignedValue>
                                    <item:MeasuredValue></item:MeasuredValue>
                                    <item:UnitName></item:UnitName>
                                    <item:Remarks>
                                        <rdf:Seq></rdf:Seq>
                                    </item:Remarks>
                                </rdf:Description>
                            </rdf:li>
                        </rdf:Seq>
                    </measurement:MeasurementItems>
                </rdf:Description>
            </photo:Measurements>
            <photo:ContractorRemarks></photo:ContractorRemarks>
        </rdf:Description>
    </rdf:RDF>
</x:xmpmeta>

調査

exif.setAttribute(ExifInterface.TAG_XMP, photoInfo.toXMP())する前(1)、後(2)、exif.saveAttributes()した後(3)でバイナリーを比較 (1) xmp情報なし (2) xmp情報なし (3) xmpが2回入っている スクリーンショット 2023-11-08 11 03 12

JangSungChul commented 8 months ago

元々のXMPの代わりにTESTJANGという文字を入れてみても2重に作成される

スクリーンショット 2023-11-08 14 46 31
JangSungChul commented 8 months ago

コード上の原因

https://android.googlesource.com/platform/frameworks/base/+/refs/heads/main/media/java/android/media/ExifInterface.java#1851 setAttributeの際に mAttributes[i].put(tag, ExifAttribute.createByte(value));が2回実行される

EXIF_TAGSの0と5番目がexifTagが存在していて、exifTag.primaryFormat == IFD_FORMAT_BYTEの判定で dataFormat = exifTag.primaryFormat;がセットされて1851行のXMPデータが2回実施される。

https://android.googlesource.com/platform/frameworks/support/+/ba80a7f1ba45dd3f664bd18914ef715402e48195/exifinterface/exifinterface/src/main/java/androidx/exifinterface/media/ExifInterface.java#3782 IFD_TIFF_TAGSが2つある??

// List of Exif tag groups
static final ExifTag[][] EXIF_TAGS = new ExifTag[][] {
    IFD_TIFF_TAGS, IFD_EXIF_TAGS, IFD_GPS_TAGS, IFD_INTEROPERABILITY_TAGS,
    IFD_THUMBNAIL_TAGS, IFD_TIFF_TAGS, ORF_MAKER_NOTE_TAGS, ORF_CAMERA_SETTINGS_TAGS,
    ORF_IMAGE_PROCESSING_TAGS, PEF_TAGS
};
JangSungChul commented 8 months ago

Issue報告 https://issuetracker.google.com/issues/new?component=460705&template=1238586&hl=ja

Component used: Android ExifInterface
Version used: 1.3.6
Devices/Android versions reproduced on: Issue consistently reproduced across various devices, on Android versions 9 to 13.

When reporting bugs, please always include:

1. Reproduction steps:
   - Import and use the ExifInterface library version 1.3.6 in an Android project.
   - Utilize the `setAttribute` method of the ExifInterface, specifying `ExifInterface.TAG_XMP` and the corresponding XMP data.
   - Observe that the generated image contains duplicated XMP data.
2. How reproducible the issue is on the affected device: The issue occurs consistently on every attempt across various devices and Android versions (9 to 13).
3. If known, how reproducible the issue is on other devices and OS versions: Consistently reproducible on all tested devices and OS versions.

Where possible, please also provide:

1. A project code that reproduces the issue: 
https://github.com/ncdcdev/cordova-plugin-blackboard-camera/blob/a7516c4c831967614d0f66d36470a2c8a5613fa9/src/android/ElectronicBlackBoardManager.kt#L27

2. A screen record or screenshots showing the issue: A screenshot showing the duplicated XMP data in the binary data of the photo is attached for reference.

Additional Notes: 
Upon inspection of the `setAttribute` source code in the ExifInterface library, it was found that `EXIF_TAGS` includes `IFD_TIFF_TAGS` twice. This redundancy potentially causes the XMP data to be generated twice in the resulting image, indicating a possible bug in the library's handling of XMP data.
スクリーンショット 2023-11-09 9 40 26
JangSungChul commented 8 months ago

AndroidのIssueに登録 https://issuetracker.google.com/issues/309843390

JangSungChul commented 8 months ago

担当アサインはされたが特に進捗や返信がない