kingvhit / AndroidHEIFConverter

HEICWriter & HEICReader for Android guideline
12 stars 0 forks source link

Need help on saving to JPEG. #2

Closed mechazod closed 3 years ago

mechazod commented 4 years ago

@kingvhit @at-kietvo I had already integrated the api-java lib, I have a missing part right now.

// After getting 48 tiles as bitstream files, join its and merge into 1 files by ffmpeg.
....
// Loading Color profiles and attach it.
....            
// Convert BitStream to JPG.JPEG.PNG file by FFMPEG
....
// Loading Exifdata and attach it.

Thank you in advance.

kingvhit commented 4 years ago

Hi @mechazod Currently, I can confirm that the nokia heif library is just a parser provider, it mean with this library, you can only parse and get the struct of data of a photo file (.heic format) including: exif data, bitstream data. Or you can also put the correctly data into heic struct to build the heic files from jpg file.

That why, with this library, you can not do conversion from HEIC to JPG or JPG to HEIC if you does not have correctly data.

With 4 steps above I wrote up, you can pick one of the Media Encoder/Decoder library to convert bitstream of HEIC file to JPG file.

// After getting 48 tiles as bitstream files, join its and merge into 1 files by ffmpeg. https://nokiatech.github.io/heif/examples.html => The HEIC format is support many types, you can see on the example of nokia heif library on web page. I wrote 48 tiles because I do convert the HEIC format from Apple captured by iPhone. They use a Image collections type for heic format, include 48 tiles on it, per tile is a single image item. With this library, it is very easy to check the type of a image inside with method heic.primaryImageItem -> SingleImageItem, GridImageItem, ...

After you convert per tile of image, you got 48 bitstream data, then use ffmpeg or other tool to merge 48 image into one.

About Color Profile, Exif data, heic format is using the same Exif data specs of JPG files, you just need to extract byte array data of heic file into storage, then use the other library to parse it. This is very difficult for understand, but If you are interested you can try to do.

I follow this link to implement it on Android https://github.com/liuziangexit/HEIF-Utility-Native-DLL

Overall, cause it very difficult to write a library, that why I stop to working on this repository.