See on professionaalne lahendus JPG faili tihendamiseks Java abil. Kasutage meie JPG optimeerimise API t, et luua Java s kaasaskantavat, tugevat ja turvalist tarkvara. Proovige seda veebis tasuta!
Muutke suured JPG failid väiksemaks ilma kvaliteeti kaotamata. Kustutage mittevajalikud ja kasutamata andmed. Vähendage koodis JPG faili suurust. Java teek pakub arendajatele integreeritud API d JPG sisu optimeerimiseks.
Java teek on iseseisev lahendus ja see ei nõua kolmanda osapoole tarkvara installimist.
'Aspose.Words for Java' kadudeta pakkimise ja sisu sügava optimeerimise lihtsaks. Järgmine näide demonstreerib, kuidas optimeerida JPG faili Java:
// Repository path: https://releases.aspose.com/java/repo/
// Maven, where 'ver' - Aspose.Words version number, for example, 24.4.
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-words</artifactId>
<version>ver</version>
<classifier>jdk17</classifier>
</dependency>
Kopeeri
// Repository path: https://releases.aspose.com/java/repo/
// Gradle, where 'ver' - Aspose.Words version number, for example, 24.4.
compile(group: 'com.aspose', name: 'aspose-words', version: 'ver', classifier: 'jdk17')
Kopeeri
// Repository path: https://releases.aspose.com/java/repo/
// Ivy, where 'ver' - Aspose.Words version number, for example, 24.4.
<dependency org="com.aspose" name="aspose-words" rev="ver">
<artifact name="aspose-words" m:classifier="jdk17" ext="jar"/>
</dependency>
Kopeeri
// Repository path: https://releases.aspose.com/java/repo/
// Sbt, where 'ver' - Aspose.Words version number, for example, 24.4.
libraryDependencies += "com.aspose" % "aspose-words" % "ver"
Kopeeri
import com.aspose.words.*;
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertImage("Input.jpg");
ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.JPEG);
saveOptions.setJpegQuality(50);
shape.getShapeRenderer().save("Output.jpg", saveOptions);
import com.aspose.words.*;
Document doc = new Document("Input.jpg");
doc.cleanup();
NodeCollection nodes = doc.getChildNodes(NodeType.SHAPE, true);
for (Shape shape : (Iterable<Shape>) nodes)
{
if (shape.isImage())
{
// Kujutise tihendamiseks teegi valib arendaja.
BufferedImage image = ImageIO.read(shape.getImageData().toStream());
// ...
// Tihendage pilt ja seadke see tagasi kujundisse.
shape.getImageData().setImage("yourCompressedImage");
}
}
OoxmlSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.setCacheBackgroundGraphics(true);
doc.save("Output.jpg", saveOptions);
import com.aspose.words.*;
Document doc = new Document("Input.jpg");
doc.cleanup();
NodeCollection nodes = doc.getChildNodes(NodeType.SHAPE, true);
for (Shape shape : (Iterable<Shape>) nodes)
{
if (shape.isImage)
{
// Kujutise tihendamiseks teegi valib arendaja.
BufferedImage image = ImageIO.read(shape.getImageData().toStream());
// ...
// Tihendage pilt ja seadke see tagasi kujundisse.
shape.getImageData().setImage("yourCompressedImage");
}
}
doc.save("Output.jpg");
import com.aspose.words.*;
Document doc = new Document("Input.jpg");
doc.cleanup();
NodeCollection nodes = doc.getChildNodes(NodeType.SHAPE, true);
for (Shape shape : (Iterable<Shape>) nodes)
{
if (shape.isImage())
{
// Kujutise tihendamiseks teegi valib arendaja.
BufferedImage image = ImageIO.read(shape.getImageData().toStream());
// ...
// Tihendage pilt ja seadke see tagasi kujundisse.
shape.getImageData().setImage("yourCompressedImage");
}
}
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
saveOptions.setCompressionLevel(CompressionLevel.MAXIMUM);
doc.save("Output.jpg", saveOptions);
import com.aspose.words.*;
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertImage("Input.jpg");
ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.JPEG);
saveOptions.setJpegQuality(50);
shape.getShapeRenderer().save("Output.jpg", saveOptions);
Hoidame oma Java pakette Maveni hoidlates. 'Aspose.Words for Java' on tavaline JAR fail. Järgige samm-sammult juhiseid selle installimiseks oma Java arendajakeskkonda.
Java SE 7 ja uuemaid Java versioone. Java SE 6 jaoks eraldi paketti juhuks, kui olete kohustatud seda aegunud JRE kasutama.
Meie Java pakett on platvormideülene ja töötab kõigis JVM rakendusega Microsoft Windows, Linux, macOS, Android ja iOS.
Lisateavet valikuliste pakettide sõltuvuste kohta, nagu JogAmp JOGL, Harfbuzz fondimootor, Java Advanced Imaging JAI, vaadake toote dokumentatsioonist.
Saate optimeerida faile paljudes teistes failivormingutes: