Git Product home page Git Product logo

heif-converter's Introduction

HEIF-converter

GitHub release (latest by date) GitHub
GitHub followers GitHub stars GitHub forks

Converter for High Efficiency Image Format(HEIF) to other image format

Available formats

  • JPEG
  • PNG
  • WEBP

Download

Gradle

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}
dependencies {
  implementation 'com.github.lincollincol:HEIF-converter:1.5'
}

Maven

<repositories>
  <repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
  </repository>
</repositories>
<dependency>
  <groupId>com.github.lincollincol</groupId>
  <artifactId>Repo</artifactId>
  <version>1.5</version>
</dependency>

Usage

HeifConverter.useContext(this)
                .fromUrl("https://github.com/nokiatech/heif/raw/gh-pages/content/images/crowd_1440x960.heic")
                .withOutputFormat(HeifConverter.Format.PNG)
                .withOutputQuality(100) // optional - default value = 100. Available range (0 .. 100)
                .saveFileWithName("Image_Converted_Name_2") // optional - default value = uuid random string
                .saveResultImage(true) // optional - default value = true
                .convert {
                    println(it[HeifConverter.Key.IMAGE_PATH] as String)
                    resultImage.setImageBitmap((it[HeifConverter.Key.BITMAP] as Bitmap))
                }

convert function

  • Lambda, inside convert method, will return map of Objects. If you want to get result bitmap, you need to get value by libarry key HeifConverter.Key.BITMAP and cast it to Bitmap

  • If you need path to converted image - use HeifConverter.Key.IMAGE_PATH key and cast map value to String.

saveResultImage function

  • Set false, if you need bitmap only without saving.
  • You can skip this function if you want to save converted image, because it is true by default

saveFileWithName function

  • Use custom file name.
  • Skip this function if you don't need custom converted image name, because UUID generate unique name by default.

withOutputQuality function

  • Use this function if you need custom output quality.
  • Skip this function if you don't need custom output quality, default quality - 100

withOutputFormat function

  • Set output image format.
  • Use values from HeifConverter.Format. (Current available: PNG, JPEG, WEBP).

from (Source)

  • Convert heic image from sources such file, url, bytes, input stream etc.
  • You can call this function only one time. If you call this function few times - converter will use last called source.

Based on

heifreader by yohhoy

License

MIT License

Copyright (c) 2022 lincollincol

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

heif-converter's People

Contributors

jordond avatar lincollincol avatar nickm-27 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

heif-converter's Issues

Release 1.4 is broken

Describe the bug

If you check the jitpack logs you'll see that the build failed and no artifacts were generated.

To Reproduce
Steps to reproduce the behavior:

  1. Update from 1.3 to 1.4
  2. Sync project
  3. Failed

java.lang.RuntimeException: infe not implemented (crash)

Describe the bug
Give file source call convert it crashes

java.lang.RuntimeException: infe not implemented 
   at linc.com.heifconverter.iso14496.part12.ItemInfoEntry.getContent(ItemInfoEntry.kt:27)

To Reproduce
Steps to reproduce the behavior:

  1. download heic sample from https://filesamples.com/formats/heic
  2. try to convert crash

Expected behavior
it should convert the file

Screenshots
no screenshots needed

Smartphone (please complete the following information):

  • Device: android emulator
  • OS: pie 9

NoSuchMethodError

Running in Android 10 is successful ,but Android 7.1.1 is failure
HeifConverter.useContext(this)
.fromFile("/sdcard/nut/IMG_61072668.heic")
.withOutputFormat(HeifConverter.Format.JPEG)
.withOutputQuality(100)
.saveFileWithName("Image_Converted_Name")
.saveResultImage(true)
.convert {
println(it[HeifConverter.Key.IMAGE_PATH] as String)
resultImage.setImageBitmap((it[HeifConverter.Key.BITMAP] as Bitmap))
}

This file exists!!!

java.lang.NoSuchMethodError: No virtual method limit(I)Ljava/nio/ByteBuffer; in class Ljava/nio/ByteBuffer; or its super classes (declaration of 'java.nio.ByteBuffer' appears in /system/framework/core-oj.jar)
    at org.mp4parser.AbstractBoxParser.parseBox(AbstractBoxParser.java:84)
    at org.mp4parser.BasicContainer.initContainer(BasicContainer.java:107)
    at org.mp4parser.IsoFile.<init>(IsoFile.java:57)
    at org.mp4parser.IsoFile.<init>(IsoFile.java:52)
    at linc.com.heifconverter.HeifReader.decodeByteArray(HeifReader.kt:106)
    at linc.com.heifconverter.HeifReader.decodeFile(HeifReader.kt:150)
    at linc.com.heifconverter.HeifConverter$convert$2$1.invokeSuspend(HeifConverter.kt:139)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

enable user to set file path along with the filename

Presently, we can only specify the filename for the converted file, and it is automatically saved to a predetermined location. It would be beneficial to provide users with the option to select their own file-saving path.

Crashes

Thanks for this library.

But i get this error when i implement in my project.

Process: heic.jpg.converter.heictojpgconverterapp, PID: 6189
java.lang.RuntimeException: infe not implemented
at linc.com.heifconverter.iso14496.part12.ItemInfoEntry.getContent(ItemInfoEntry.kt:27)
at org.mp4parser.support.AbstractBox.verify(AbstractBox.java:193)
at org.mp4parser.support.AbstractBox.parseDetails(AbstractBox.java:146)
at linc.com.heifconverter.iso14496.part12.ItemInfoBox.parse(ItemInfoBox.kt:33)
at org.mp4parser.AbstractBoxParser.parseBox(AbstractBoxParser.java:116)
at org.mp4parser.BasicContainer.initContainer(BasicContainer.java:107)
at org.mp4parser.boxes.iso14496.part12.MetaBox.parse(MetaBox.java:107)
at org.mp4parser.AbstractBoxParser.parseBox(AbstractBoxParser.java:116)
at org.mp4parser.BasicContainer.initContainer(BasicContainer.java:107)
at org.mp4parser.IsoFile.(IsoFile.java:57)
at org.mp4parser.IsoFile.(IsoFile.java:52)
at linc.com.heifconverter.HeifReader.decodeByteArray(HeifReader.kt:129)
at linc.com.heifconverter.HeifReader.decodeFile(HeifReader.kt:178)
at linc.com.heifconverter.HeifReader.decodeStream(HeifReader.kt:243)
at linc.com.heifconverter.HeifReader.decodeUrl(HeifReader.kt:262)
at linc.com.heifconverter.HeifConverter$convert$2$1.invokeSuspend(HeifConverter.kt:140)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.