Skip to content

Commit 2a8cb33

Browse files
author
Evgeniy Sidenko
committed
Updated for Aspose.Imaging for Java 22.5
1 parent 722fee0 commit 2a8cb33

File tree

6 files changed

+130
-31
lines changed

6 files changed

+130
-31
lines changed

Examples/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.aspose</groupId>
55
<artifactId>imaging-java-examples</artifactId>
6-
<version>22.3</version>
6+
<version>22.5</version>
77
<packaging>jar</packaging>
88
<properties>
99
<maven.compiler.source>1.8</maven.compiler.source>
@@ -15,7 +15,7 @@
1515
<dependency>
1616
<groupId>com.aspose</groupId>
1717
<artifactId>aspose-imaging</artifactId>
18-
<version>22.3</version>
18+
<version>22.5</version>
1919
<classifier>jdk16</classifier>
2020
<type>jar</type>
2121
</dependency>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.aspose.imaging.examples.ModifyingImages.dicom;
2+
3+
import com.aspose.imaging.Image;
4+
import com.aspose.imaging.examples.Logger;
5+
import com.aspose.imaging.examples.Utils;
6+
import com.aspose.imaging.fileformats.dicom.DicomImage;
7+
import com.aspose.imaging.imageoptions.DicomOptions;
8+
import com.aspose.imaging.xmp.XmpPacketWrapper;
9+
import com.aspose.imaging.xmp.schemas.dicom.DicomPackage;
10+
11+
import java.util.List;
12+
13+
public class SupportStoringXmpTags
14+
{
15+
public static void main(String[] args)
16+
{
17+
Logger.startExample();
18+
// The path to the documents' directory.
19+
String dataDir = Utils.getSharedDataDir() + "dicom/";
20+
String outDir = Utils.getOutDir();
21+
22+
try (DicomImage image = (DicomImage) Image.load(dataDir + "file.dcm"))
23+
{
24+
XmpPacketWrapper xmpPacketWrapper = new XmpPacketWrapper();
25+
DicomPackage dicomPackage = new DicomPackage();
26+
27+
dicomPackage.setEquipmentInstitution("Test Institution");
28+
dicomPackage.setEquipmentManufacturer("Test Manufacturer");
29+
dicomPackage.setPatientBirthDate("19010101");
30+
dicomPackage.setPatientId("010101");
31+
dicomPackage.setPatientName("Test Name");
32+
dicomPackage.setPatientSex("M");
33+
dicomPackage.setSeriesDateTime("19020202");
34+
dicomPackage.setSeriesDescription("Test Series Description");
35+
dicomPackage.setSeriesModality("Test Modality");
36+
dicomPackage.setSeriesNumber("01");
37+
dicomPackage.setStudyDateTime("19030303");
38+
dicomPackage.setStudyDescription("Test Study Description");
39+
dicomPackage.setStudyId("02");
40+
dicomPackage.setStudyPhysician("Test Physician");
41+
42+
xmpPacketWrapper.addPackage(dicomPackage);
43+
String outputFile = outDir + "output.dcm";
44+
45+
image.save(outputFile, new DicomOptions() {{ setXmpData(xmpPacketWrapper); }});
46+
47+
48+
try (DicomImage imageSaved = (DicomImage)Image.load(outputFile))
49+
{
50+
List<String> originalDicomInfo = image.getFileInfo().getDicomInfo();
51+
List<String> imageSavedDicomInfo = imageSaved.getFileInfo().getDicomInfo();
52+
int tagsCountDiff = Math.abs(imageSavedDicomInfo.size() - originalDicomInfo.size());
53+
Logger.println("The difference between info of two dicom files: ", tagsCountDiff);
54+
}
55+
56+
new java.io.File(outputFile).delete();
57+
}
58+
59+
Logger.endExample();
60+
}
61+
}

Examples/src/main/java/com/aspose/imaging/examples/RunExamples.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.aspose.imaging.examples.ModifyingImages.dicom.DicomCompression;
2727
import com.aspose.imaging.examples.ModifyingImages.dicom.DicomToPngExample;
2828
import com.aspose.imaging.examples.ModifyingImages.dicom.ExportToDicom;
29+
import com.aspose.imaging.examples.ModifyingImages.dicom.SupportStoringXmpTags;
2930
import com.aspose.imaging.examples.ModifyingImages.dxf.ExportToDxf;
3031
import com.aspose.imaging.examples.ModifyingImages.eps.ExportEps;
3132
import com.aspose.imaging.examples.ModifyingImages.gif.CreateGifUsingAddPage;
@@ -280,7 +281,7 @@ public static void main(String[] args) throws IOException, InterruptedException,
280281
//// DICOM
281282
//// =====================================================
282283
//// =====================================================
283-
284+
SupportStoringXmpTags.main(args);
284285
DicomCompression.main(args);
285286
DicomToPngExample.main(args);
286287
AdjustBrightnessDICOM.main(args);
4.98 KB
Binary file not shown.
89.1 KB
Binary file not shown.

README.md

Lines changed: 65 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
![GitHub all releases](https://img.shields.io/github/downloads/aspose-imaging/Aspose.imaging-for-Java/total) ![GitHub](https://img.shields.io/github/license/aspose-imaging/Aspose.imaging-for-java)
2-
# Java API for Image Processing
32

4-
It is a standalone [Imaging API](https://products.aspose.com/imaging/java) consisting of Java routines that enable your Java applications to draw as well as perform basic to advanced level processing of raster & vector images.
3+
# Java API for Image Processing
54

6-
Aspose.Imaging for Java offers robust image compression and high processing speed through native byte access and a range of efficient algorithms. It not only manipulate, export and convert images but also lets you dynamically draw objects using pixel manipulation and Graphics Path.
5+
[Imaging API](https://products.aspose.com/imaging/java) is a library offering advanced image processing features. Developers can create, edit or convert images in their own application. Also Aspose. Imaging library supports drawing and work with graphic primitives. Image export and conversion (including uniform multi-page image processing) is the one of API core features along with image transformations (resize, crop, flip&rotate, binarization, grayscale, adjust), advanced image manipulation features (filtering, dithering, masking, deskewing) and memory optimization strategies.
76

87
Directory | Description
98
--------- | -----------
@@ -16,33 +15,42 @@ Directory | Description
1615
</a>
1716
</p>
1817

18+
Directory | Description
19+
--------- | -----------
20+
[Examples](Examples) | A collection of Java examples that help you learn the product features.
21+
[Plugins](Plugins) | Plugins related to Aspose.Imaging for Java product.
22+
23+
1924
## Imaging API Features
2025

21-
- Draw raster images with graphics.
22-
- Draw vector images.
23-
- Converting images to various formats.
26+
- [Draw raster images with graphics](https://docs.aspose.com/imaging/java/drawing-images-using-graphics/).
27+
- [Draw vector images](https://docs.aspose.com/imaging/java/drawing-vector-images/).
28+
- [Convert images to various formats](https://docs.aspose.com/imaging/java/converting-images/).
2429
- [Apply masking](https://docs.aspose.com/imaging/java/applying-masking-to-images/) as well as [Median & Wiener](https://docs.aspose.com/imaging/java/applying-median-and-wiener-filters/) filters.
25-
- Crop, rotate & resize images via API.
26-
- De-skew & transform images.
27-
- Set image properties.
30+
- [Crop, rotate & resize images via API](https://docs.aspose.com/imaging/java/crop-rotate-and-resize-images/).
31+
- [De-skew & transform images](https://docs.aspose.com/imaging/java/deskew-image/).
32+
- [Set image properties](https://docs.aspose.com/imaging/java/setting-properties-on-images/).
33+
- [Work with multipage image formats](https://docs.aspose.com/imaging/java/working-with-multipage-image-formats/).
2834

29-
## Read & Write Image Formats
35+
## Load & Save Image Formats
3036

31-
**Raster Formats:** JPEG2000, JPEG, BMP, TIFF, GIF, PNG, APNG\
32-
**Metafiles:** EMF, EMZ, WMF, WMZ\
33-
**Other:** SVG, SVGZ, DICOM
37+
**Raster Formats:** JPEG2000, JPEG, BMP, TIFF, GIF, PNG, DICOM\
38+
**Metafiles:** EMF, WMF\
39+
**Compressed metafiles:** EMZ, WMZ\
40+
**Other:** WebP, Svg, Svgz (compressed Svg)\
41+
**Animation:** Apng
3442

3543
## Save Images As
36-
37-
**Fixed:** PDF\
44+
**Fixed-layout:** PDF\
3845
**Photoshop:** PSD\
39-
**Markup:** HTML5 Canvas
46+
**Web:** Html5 Canvas
47+
48+
## Load Images
4049

41-
## Read Image Formats
50+
**Various:** DjVu, DNG, ODG, EPS(raster preview only), CMX, CDR, DIB, OTG, FODG
4251

43-
**Various:** DjVu, DNG, ODG, CMX, CDR, DIB, OTG, FODG, EPS (raster preview only), WEBP
4452

45-
## Supported Operating Systems
53+
## Platform Independence
4654

4755
Aspose.Imaging for Java can be virtually run in any OS where Java is installed (since JDK 1.6)
4856

@@ -59,19 +67,48 @@ Aspose.Imaging works for both x86 and x64 versions of the above listed operating
5967

6068
Aspose hosts all Java APIs at the [Aspose Repository](https://repository.aspose.com/webapp/#/artifacts/browse/tree/General/repo/com/aspose/aspose-imaging). You can easily use Aspose.BarCode for Java API directly in your Maven projects with simple configurations. For the detailed instructions please visit [Installing Aspose.Imaging for Java from Maven Repository](https://docs.aspose.com/imaging/java/installation/) documentation page.
6169

62-
## Crop EMF Image by Rectangle
70+
## Resize a JPG Image
6371

64-
```java
65-
try (MetafileImage metaImage = (MetafileImage) Image.load(dataDir + "Picture1.emf"))
72+
``` java
73+
try (Image image = Image.load(dir + "template.jpg"))
6674
{
67-
// create an instance of Rectangle class with desired size
68-
Rectangle rectangle = new Rectangle(10, 10, 100, 100);
75+
image.resize(300, 300);
76+
image.save(dir + "output.jpg");
77+
}
78+
```
79+
80+
## Create & Manipulate PNG via API
6981

70-
// perform the crop operation on object of Rectangle class
71-
metaImage.crop(rectangle);
82+
``` java
83+
// image width and height
84+
int width = 500;
85+
int height = 300;
7286

73-
// save the result in PNG format
74-
metaImage.save(dataDir + "CropbyRectangle_out.png", new PngOptions());
87+
// where created image to store
88+
String path = "createdImage.png";
89+
// create options
90+
try (PngOptions options = new PngOptions())
91+
{
92+
options.setSource(new FileCreateSource(path, false));
93+
try (PngImage image = (PngImage)Image.create(options, width, height))
94+
{
95+
// create and initialize an instance of Graphics class
96+
// and Clear Graphics surface
97+
Graphics graphic = new Graphics(image);
98+
graphic.clear(Color.getGreen());
99+
// draw line on image
100+
graphic.drawLine(new Pen(Color.getBlue()), 9, 9, 90, 90);
101+
102+
// resize image
103+
int newWidth = 400;
104+
image.resizeWidthProportionally(newWidth, ResizeType.LanczosResample);
105+
106+
// crop the image to specified area
107+
com.aspose.imaging.Rectangle area = new com.aspose.imaging.Rectangle(10,10,200,200);
108+
image.crop(area);
109+
110+
image.save();
111+
}
75112
}
76113
```
77114

0 commit comments

Comments
 (0)