how I can convert heic to jpg with swift?

Hi,

how i can convert heic to jpg using swift, for example, i get a photo the camera roll in jpg and next, i can convert this in heic.


Thanks

Replies

Found on reddit h ttps://www.reddit.com/r/ios/comments/6l02ry/how_to_convert_heic_format_to_jpg_ios_11_public/dn6o3al/

this python converter:

h ttps://github.com/gpac/gpac/files/1312966/heic.py.zip


Hope it will help you on how to do in Swift

Can i use code by python in one app for iphone/ipad that use swift?



sorry for my bad english

Have a look here:

h ttps://forums.developer.apple.com/thread/30092

and here:

h ttps://stackoverflow.com/questions/40380893/running-a-python-script-from-swift

This one also, to see how to execute Python directly:

h ttp://ericasadun.com/2016/12/04/running-python-in-xcode-step-by-step/


Other option is to use Python code as a model to write the same in Swift.

Hello there! If you still haven't figure out the way to do so, you can use a tool that can convert HEIC to JPG online for free. One of the few converters that can do this is Apowersoft Free HEIC to JPG. You may visit the site on any browsers and convert without hassle. For easier process, I suggest you use your computer. 🙂 Hope this helps!

If you forget to convert HEIC to JPG ,It's hard to open your picture on a computer

I've tried it many times on my computer , even if thses photos has been moved to my computer ,

But I can't open it on the computer, wrong format ,I clicked it many times and it didn't work ,

Hello there! If you still haven't figure out the way to do so, you can use a tool that can convert HEIC to JPG online for free. One of the few converters that can do this is Apowersoft Free HEIC to JPG. You may visit the site on any browsers and convert without hassle. For easier process, I suggest you use your computer. Hope this helps!


You want all that? How about if every camera manufacturer would just implement a TAR and just package all the files to single container?

TAR isn't a compression like ZIP, RAR etc.
TAR is very simple file standard to contain any file to single one, you can place any file in it without any compression (when supporting the random access) or then just output it through different compressions if wanted.

I've heard a lot of friends who use the iPhone have feedback on this,the HEIC is the latest product technology launched by the iPhone, and their goal is to effectively reduce the memory capacity of images.But not good, except for the iPhone, other device doesn't seem to support HEIC ,if iPhone user want to move photos to Mac/Computer ,It's necessary to convert HEIC to JPG,

There are many options on Google, but they are not necessarily all useful, even if they can be used to convert HEIC to JPG, but the clarity of the picture will be affected ,I've heard a lot of friends who use the iPhone have feedback on this,the HEIC is the latest product technology launched by the iPhone, and their goal is to effectively reduce the memory capacity of images.But not good, except for the iPhone, other device doesn't seem to support HEIC ,if iPhone user want to move photos to Mac/Computer ,

Nokia tech has a github project about HEIC and it is written in c++. It is based on the well-known ISO Base Media File Format (ISOBMFF) standard. HEIF Reader/Writer Engine is an implementation of HEIF standard in order to demonstrate its powerful features and capabilities. An here is a live example of how to use this library to build great software.

To convert HEIC (High Efficiency Image Format) images to JPG format using Swift, you can utilize the UIImage and Data APIs provided by iOS. Here's an example of how you can convert HEIC images to JPG:

import UIKit

func convertHEICtoJPG(heicData: Data) -> Data? { guard let image = UIImage(data: heicData) else { print("Failed to create UIImage from HEIC data") return nil }

guard let jpgData = image.jpegData(compressionQuality: 1.0) else {
    print("Failed to convert UIImage to JPG data")
    return nil
}

return jpgData

}

In this example, the convertHEICtoJPG function takes an input Data object containing the HEIC image data and returns a Data object containing the converted JPG image data.

Here's how you can use this function to convert a HEIC image:

// Assuming you have the HEIC image data stored in a Data object let heicData: Data = ...

if let jpgData = convertHEICtoJPG(heicData: heicData) { // Use the converted JPG data as needed // For example, you can save it to a file or upload it to a server // ... } else { // Conversion failed, handle the error or notify the user // ... }

Make sure to handle any potential errors, such as if the input HEIC data cannot be converted to a UIImage or if the conversion to JPG data fails.

Remember to include the appropriate error handling and consider any additional steps required for your specific use case, such as saving the converted JPG data to a file or uploading it to a server.

Note: HEIC images are supported starting from iOS 11. If you're targeting older versions of iOS, you may need to consider using third-party libraries or tools for HEIC to JPG conversion.