Important: Please read the Qt Code of Conduct -

HEIC Image Conversion? Is it possible?

  • The app I'm working on currently has a feature where I create a zip file, bundle a report and associated images and send the zip to someone. Many times, the images would fail to show in the pdf that gets generated. We construct html and convert to pdf, btw. After some debugging, I found that the extension of the images is HEIC. Well, I didn't know what that was until I researched.

    I know that there is a setting on iOS for saving images in either High Efficiency or Most Compatible but I'd really rather not force users to make a system wide setting change like that. Rather, I'd like to convert the images into JPG before bundling them in the zip. Is this possible?

    I'm also aware that there is a bug for this and I can apply a patch to the qtimageformats project but I'm not sure if this will offer a conversion mechanism.

    FYI, I'm using 5.11.1 and 4.7 so I'm fully up to date.

  • Qt Champions 2016

    @ebonnett seems that you have to add some native iOS code.
    found this - but not tested yet !

    NSString *heicImageFilePath = @"<file/path/to/heic/image>";
    NSString *ext = [heicImageFilePath pathExtension];
    if ([ext isEqualToString:@"heic"]) {
       // create new jpeg file from input heic filepath
        NSString* fname = [imageFilePath stringByDeletingPathExtension];
        NSString* newJpgPath = [fname stringByAppendingPathExtension:@"jpg"];;
        NSURL *url = [NSURL fileURLWithPath:imageFilePath];
        NSData *data = [NSData dataWithContentsOfURL:url];
        UIImage *image = [UIImage imageWithData:data];
        NSData *jpgImageData = UIImageJPEGRepresentation(image, 0.7);
        [jpgImageData writeToFile:newJpgPath atomically:YES];

    also take a look here

  • @ekkescorner Thanks for the tip. I wonder how long it will be before there is a built in converter? This presents a problem with emailing photos from iOS to any other platform, which my application does... unless of course you force the users to store their photos in jpg, but this is not the default behavior (nor should it be).

  • Qt Champions 2016

    @ebonnett BTW: Android 9 now also supports HEIF (HEIC)
    conversion between JPG and HEIC can be done with

    have you opened an issue for Qt to support HEIC ?

  • This is how we do it on Qt 5.12.4 on iOS. On macOS, Qt might have a Qt image plugin for this too:

    // pseudo code adapted for
    QByteArray fromHEICToJPEG(const QByteArray &imageData) {
        QBuffer buffer;
        QImageReader imageReader(&buffer);
        qDebug() << "width"<< imageReader.size().width() << "height" << imageReader.size().height() << "format"<<imageReader.format() << imageReader.subType();
        // ^^Qt auto detects the "heic" format
        QImage resizeImage =;
        QByteArray outBa;
        QBuffer outBuffer(&outBa);;, "JPEG");
        return outBa;

Log in to reply