Skip to content

Commit 855a0c6

Browse files
author
Evgeniy Sidenko
committed
Initial commit
Openize.HEIC for Java v.25.4.0
0 parents  commit 855a0c6

210 files changed

Lines changed: 553506 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

LICENSE

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Openize.HEIC is available under Openize License.
2+
3+
This license is derived from BSD 2 Clause License and Third-party patents clause.
4+
5+
Copyright (c) 2024-2025 Openize Pty Ltd.
6+
7+
Redistribution and use in source and binary forms, with or without modification, are permitted
8+
provided that the following conditions are met:
9+
1. Redistributions of source code must retain the above copyright notice, this list of conditions
10+
and the following disclaimer.
11+
2. Redistributions in binary form must reproduce the above copyright notice, this list of
12+
conditions and the following disclaimer in the documentation and/or other materials provided with
13+
the distribution.
14+
15+
THIRD-PARTY PATENTS.
16+
Openize.HEIC contains HEVC/H.265 image compression/decompression technologies that are covered by
17+
third party patents. Openize does not and cannot grant You a patent license for the utilization
18+
of HEVC/H.265 image compression/decompression technologies. If You create End User Software that
19+
utilizes the HEVC/H.265 image compression/decompression technologies included in Openize.HEIC then
20+
You are responsible for obtaining any required third-party patent licenses for the deployment and
21+
distribution of Your End User Software. You agree to indemnify and hold Openize harmless from any
22+
and all patent claims that arise from the deployment and distribution of Your End User Software
23+
that utilizes the HEVC/H.265 image compression/decompression technologies included in Openize.HEIC.
24+
If You plan on using the HEVC/H.265 image compression/decompression technologies included in
25+
Openize.HEIC in Your End User Software and You would like contact details for the patent holders,
26+
then please consider https://en.wikipedia.org/wiki/High_Efficiency_Video_Coding.
27+
28+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR
29+
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
30+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
31+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
34+
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
35+
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
# Openize.HEIC for Java
2+
3+
![Openize.HEIC](publish/openize_heic_java.png)
4+
5+
Openize.HEIC is an open source SDK implementing the ISO/IEC 23008-12:2017 HEIF file format decoder.
6+
7+
It is written from scratch and has a plain Java API to enable a simple integration into other software.
8+
9+
## Supported features
10+
11+
Openize.HEIC has support for:
12+
* HEIC coded static images;
13+
* I slices;
14+
* 4:2:0, 4:2:2 and 4:4:4 chroma subsampling.
15+
* HEIC coded animations that use several I slices;
16+
* multiple images in a file;
17+
* alpha channels, depth maps, thumbnails, auxiliary images;
18+
* correct color transform according to embedded color profiles;
19+
* image transformations (crop, mirror, rotate), overlay images.
20+
21+
Openize.HEIC doesn't support:
22+
* HDR images;
23+
* reading EXIF and XMP metadata;
24+
* color transform according to EXIF contained color profiles;
25+
* HEIC coded animations that use P and B slices;
26+
* deblocking filter.
27+
28+
## Usage examples
29+
30+
### Read .heic file to int array with argb32 data
31+
32+
``` java
33+
try (IOFileStream fs = new IOFileStream("filename.heic", IOMode.READ))
34+
{
35+
HeicImage image = HeicImage.load(fs);
36+
int[] pixels = image.getInt32Array(openize.heic.decoder.PixelFormat.Argb32);
37+
}
38+
```
39+
40+
### Convert .heic file to .jpg using Java ImageIO
41+
42+
``` java
43+
try (IOFileStream fs = new IOFileStream("filename.heic", IOMode.READ))
44+
{
45+
HeicImage image = HeicImage.load(fs);
46+
47+
int[] pixels = frames.get(key).getInt32Array(PixelFormat.Argb32);
48+
var width = (int)image.Width;
49+
var height = (int)image.Height;
50+
51+
BufferedImage image2 = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
52+
image2.setRGB(0, 0, width, height, pixels, 0, width);
53+
ImageIO.write(image2, "JPEG", new File("output.jpg"));
54+
}
55+
```
56+
57+
### Convert .heic file to .png using Java ImageIO
58+
``` java
59+
try (IOFileStream fs = new IOFileStream("filename.heic", IOMode.READ))
60+
{
61+
HeicImage image = HeicImage.load(fs);
62+
63+
int[] pixels = frames.get(key).getInt32Array(PixelFormat.Argb32);
64+
var width = (int)image.Width;
65+
var height = (int)image.Height;
66+
67+
BufferedImage image2 = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
68+
image2.setRGB(0, 0, width, height, pixels, 0, width);
69+
ImageIO.write(image2, "PNG", new File("output.png"));
70+
}
71+
```
72+
73+
### Convert .heic file to .png using Java ImageIO
74+
``` java
75+
try (IOFileStream fs = new IOFileStream("filename.heic", IOMode.READ))
76+
{
77+
HeicImage image = HeicImage.load(fs);
78+
79+
int[] pixels = image.getInt32Array(PixelFormat.Argb32);
80+
int width = (int)image.getWidth();
81+
int height = (int)image.getHeight();
82+
int i = 0;
83+
84+
BufferedImage outImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
85+
outImage.setRGB(0, 0, width, height, pixels, 0, width);
86+
ImageIO.write(outImage, "PNG", new File("output.png"));
87+
}
88+
```
89+
90+
### Convert .heic collection to a set of .png files
91+
``` java
92+
try (IOFileStream fs = new IOFileStream("filename.heic", IOMode.READ))
93+
{
94+
HeicImage image = HeicImage.load(fs);
95+
96+
final Map<Long, HeicImageFrame> frames = image.getFrames();
97+
for (Long key : frames.keySet())
98+
{
99+
int width = (int)frames.get(key).getWidth();
100+
int height = (int)frames.get(key).getHeight();
101+
int[] pixels = frames.get(key).getInt32Array(PixelFormat.Argb32);
102+
103+
BufferedImage image2 = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
104+
image2.setRGB(0, 0, width, height, pixels, 0, width);
105+
ImageIO.write(image2, "PNG", new File("output"+key+".png"));
106+
}
107+
}
108+
```
109+
110+
## Documentation
111+
112+
All public classes, methods and properties are documented in corresponding API_README:
113+
* [/Openize.Heic.Decoder/docs/API_README.md](https://github.com/openize-heic/Openize.HEIC-for-Java/blob/main/docs/Openize.Heic.Decoder/API_README.md) for Openize.Heic.Decoder;
114+
* [/Openize.IsoBmff/docs/API_README.md](https://github.com/openize-heic/Openize.HEIC-for-Java/blob/main/docs/Openize.IsoBmff/API_README.md) for Openize.IsoBmff.
115+
116+
### HeicImage
117+
118+
#### Methods
119+
Name | Type | Description | Parameters | Notes
120+
------------ | ------------- | ------------- | ------------- | -------------
121+
**load** | **HeicImage** | Reads the file meta data and creates a class object for further decoding of the file contents. | `Stream stream` - File stream. | This operation does not decode pixels. Use the default frame methods GetByteArray or GetInt32Array afterwards in order to decode pixels.
122+
**canLoad** | **boolean** | Checks if the stream can be read as a heic image. Returns true if file header contains heic signarure, false otherwise | `Stream stream` - File stream. |
123+
**getByteArray** | **byte[]** | Get pixel data of the default image frame in the format of byte array.<br />Each three or four bytes (the count depends on the pixel format) refer to one pixel left to right top to bottom line by line.<br />Returns null if frame does not contain image data. | `PixelFormat pixelFormat` - Pixel format that defines the order of colors and the presence of alpha byte.<br />`Rectangle boundsRectangle` - Bounds of the requested area.
124+
**getInt32Array** | **int[]** | Get pixel data of the default image frame in the format of integer array.<br />Each int value refers to one pixel left to right top to bottom line by line.<br />Returns null if frame does not contain image data. | `PixelFormat pixelFormat` - Pixel format that defines the order of colors.<br />`Rectangle boundsRectangle` - Bounds of the requested area.
125+
126+
127+
#### Properties
128+
Name | Type | Description
129+
------------ | ------------- | -------------
130+
**Frames** | **Map<Long, HeicImageFrame>** | Dictionary of public Heic image frames with access by identifier.
131+
**AllFrames** | **Map<Long, HeicImageFrame>** | Dictionary of all Heic image frames with access by identifier.
132+
**DefaultFrame** | **HeicImageFrame** | Returns the default image frame, which is specified in meta data.
133+
134+
### HeicImageFrame
135+
136+
#### Methods
137+
Name | Type | Description | Parameters
138+
------------ | ------------- | ------------- | -------------
139+
**getByteArray** | **byte[]** | Get pixel data in the format of byte array. Each three or four bytes (the count depends on the pixel format) refer to one pixel left to right top to bottom line by line. | `PixelFormat pixelFormat` - Pixel format that defines the order of colors and the presence of alpha byte. `Rectangle boundsRectangle` - Bounds of the requested area.
140+
**getInt32Array** | **int[]** | Get pixel data in the format of integer array. Each int value refers to one pixel left to right top to bottom line by line. | `PixelFormat pixelFormat` - Pixel format that defines the order of colors. `Rectangle boundsRectangle` - Bounds of the requested area.
141+
**getTextData** | **String** | Get frame text data. Exists only for mime frame types. |
142+
143+
### Properties
144+
Name | Type | Description
145+
------------ | ------------- | -------------
146+
**ImageType** | **ImageFrameType** | Type of an image frame content.
147+
**Width** | **long** | Width of the image frame in pixels.
148+
**Height** | **long** | Height of the image frame in pixels.
149+
**HasAlpha** | **boolean** | Indicates the presence of transparency of transparency layer. True if frame is linked with alpha data frame, false otherwise.
150+
**IsHidden** | **boolean** | Indicates the fact that frame is marked as hidden. True if frame is hidden, false otherwise.
151+
**IsImage** | **boolean** | Indicates the fact that frame contains image data. True if frame is image, false otherwise.
152+
**IsDerived** | **boolean** | Indicates the fact that frame contains image transform data and is inherited from another frame(-s). True if frame is derived, false otherwise.
153+
**DerivativeType** | **BoxType** | Indicates the type of derivative content if the frame is derived.
154+
**AuxiliaryReferenceType** | **AuxiliaryReferenceType** | Indicates the type of auxiliary reference layer if the frame type is auxiliary.
155+
**NumberOfChannels** | **byte** | Number of channels with color data.
156+
**BitsPerChannel** | **byte[]** | Bits per channel with color data.
157+
158+
## License
159+
Openize.HEIC is available under [Openize License](https://github.com/openize-heic/Openize.HEIC-for-Java/blob/main/LICENSE).
160+
> [!CAUTION]
161+
> Openize does not and cannot grant You a patent license for the utilization of HEVC/H.265 image compression/decompression technologies.
162+
163+
Openize.HEIC uses Openize.IsoBmff that is distributed under [MIT License](https://github.com/openize-heic/Openize.HEIC-for-Java/blob/main/licenses/Openize.IsoBmff/LICENSE).
164+
165+
## OSS Notice
166+
Sample files used for tests and located in the "https://github.com/openize-heic/Openize.HEIC-for-Java/blob/main/Openize.Heic.Tests/TestsData/samples/nokia" folder belong to Nokia Technologies and are used according to [Nokia High-Efficiency Image File Format (HEIF) License](https://github.com/nokiatech/heif/blob/master/LICENSE.TXT)
167+
168+
> Licensed Field means the non-commercial purposes of evaluation, testing and academic research in each non-commercial case to use, run, modify (in a way that still complies with the Specification) and copy the Software to (a) generate, using one or more encoded pictures as inputs, a file complying with the Specification and including the one or more encoded pictures that were given as inputs; and/or (b) read a file complying with the Specification, resulting into one or more encoded pictures included in the file as outputs.

0 commit comments

Comments
 (0)