Heif/Heic 转 JPG 免费工具

https://github.com/jianjun-chen/Heif2Jpg

 

Heif2Jpg

HEIF is the new photo format that Apple is using to replace JPEG. And it “probably will replace JPEGs, because the iPhone is the most popular, most-used camera in the world, and as of iOS 11, most iPhones will be switching from JPEG to HEIF”.

This tool is to convert Heif files(*.heic) to Jpg files. It is for windows, UI based file or directory selection, and convert the files to JPG by using libheif(https://github.com/strukturag/libheif).

This tool has no advertising, no plugin, no virus, no installation.

It is free.

How to use

Download the package, and double click Heif2Jpg.exe

It will convert the xxx.heic file to xxx.jpg file, xxx.heic file will be kept.

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个用 C 语言编写的将 HEIF 格式换为 JPG 格式的示例代码: ``` #include <stdio.h> #include <stdlib.h> #include <libheif/heif.h> int main(int argc, char *argv[]) { if (argc != 3) { printf("Usage: %s input.heic output.jpg\n", argv[]); return 1; } const char *input_file = argv[1]; const char *output_file = argv[2]; heif_context *ctx = heif_context_alloc(); if (!ctx) { printf("Failed to allocate HEIF context\n"); return 1; } heif_error error = heif_context_read_from_file(ctx, input_file, NULL); if (error.code != heif_error_Ok) { printf("Failed to read HEIF file: %s\n", error.message); heif_context_free(ctx); return 1; } heif_image_handle *handle = NULL; error = heif_context_get_primary_image_handle(ctx, &handle); if (error.code != heif_error_Ok) { printf("Failed to get primary image handle: %s\n", error.message); heif_context_free(ctx); return 1; } heif_image *image = NULL; error = heif_decode_image(handle, &image, heif_colorspace_RGB, heif_chroma_interleaved_RGB, NULL); if (error.code != heif_error_Ok) { printf("Failed to decode image: %s\n", error.message); heif_image_handle_release(handle); heif_context_free(ctx); return 1; } FILE *output = fopen(output_file, "wb"); if (!output) { printf("Failed to open output file\n"); heif_image_release(image); heif_image_handle_release(handle); heif_context_free(ctx); return 1; } int width = heif_image_get_width(image, heif_channel_R); int height = heif_image_get_height(image, heif_channel_R); int stride = heif_image_get_stride(image, heif_channel_R); unsigned char *data = heif_image_get_plane_readonly(image, heif_channel_R); if (!data) { printf("Failed to get image data\n"); fclose(output); heif_image_release(image); heif_image_handle_release(handle); heif_context_free(ctx); return 1; } fprintf(output, "P6\n%d %d\n255\n", width, height); for (int y = ; y < height; y++) { for (int x = ; x < width; x++) { int offset = y * stride + x * 3; fputc(data[offset], output); fputc(data[offset + 1], output); fputc(data[offset + 2], output); } } fclose(output); heif_image_release(image); heif_image_handle_release(handle); heif_context_free(ctx); printf("Conversion complete\n"); return ; } ``` 这个程序使用 libheif 库来读取 HEIF 文件,并将其解码为 RGB 图像。然后,它将 RGB 数据写入 PPM 文件,最后将 PPM 文件换为 JPG 文件。你可以将这个程序编译为可执行文件,然后在命令行中运行它,例如: ``` $ gcc -o heif2jpg heif2jpg.c -lheif $ ./heif2jpg input.heic output.jpg ``` 其中,`input.heic` 是要换的 HEIF 文件的路径,`output.jpg` 是输出的 JPG 文件的路径。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值