Sukurkite JPG apdorojimo programinę įrangą Node.js naudodami JPG Optimization API. Šis galingas Node.js sprendimas padeda be vargo optimizuoti ir sumažinti JPG failų dydį. Išbandykite JPG glaudinimo galimybes internete nemokamai!
Sumažinkite didelius JPG failus neprarandant kokybės. Ištrinkite nereikalingus ir nenaudojamus duomenis. JPG failo dydį kode. JavaScript biblioteka suteikia kūrėjams integruotą API, skirtą JPG turiniui optimizuoti.
JavaScript biblioteka yra atskiras sprendimas ir jai nereikia įdiegti jokios trečiosios šalies programinės įrangos.
Su 'Aspose.Words for Node.js via .NET' lengvas glaudinimas ir gilus turinio optimizavimas. Toliau pateiktame pavyzdyje parodyta, kaip optimizuoti JPG failo JavaScript:
npm install @aspose/words
Kopijuoti
const aw = require('@aspose/words');
var doc = new aw.Document()
var builder = new aw.DocumentBuilder(doc)
shape = builder.insertImage("Input.jpg")
var saveOptions = new aw.Saving.ImageSaveOptions(aw.SaveFormat.Jpeg)
saveOptions.jpegQuality = 50
shape.getShapeRenderer().save("Output.jpg", saveOptions)
const aw = require('@aspose/words');
var doc = new aw.Document("Input.jpg");
doc.cleanup();
var shapes = doc.getChildNodes(aw.NodeType.Shape, true)
for (var shape of shapes) {
if (shape.hasImage()) {
// Kūrėjas turi pasirinkti vaizdų glaudinimo biblioteką.
const imageData = shape.getImageData().toStream();
// ...
// Suspausti vaizdą ir nustatykite jį atgal į formą.
shape.getImageData().setImage(compressedImageBuffer);
}
}
var saveOptions = new aw.Saving.PdfSaveOptions()
saveOptions.cacheBackgroundGraphics = true
doc.save("Output.jpg", saveOptions)
const aw = require('@aspose/words');
var doc = new aw.Document("Input.jpg");
doc.cleanup();
var shapes = doc.getChildNodes(aw.NodeType.Shape, true)
for (var shape of shapes) {
if (shape.hasImage()) {
// Kūrėjas turi pasirinkti vaizdų glaudinimo biblioteką.
const imageData = shape.getImageData().toStream();
// ...
// Suspausti vaizdą ir nustatykite jį atgal į formą.
shape.getImageData().setImage(compressedImageBuffer);
}
}
doc.save("Output.jpg")
const aw = require('@aspose/words');
var doc = new aw.Document("Input.jpg");
doc.cleanup();
var shapes = doc.getChildNodes(aw.NodeType.Shape, true)
for (var shape of shapes) {
if (shape.hasImage()) {
// Kūrėjas turi pasirinkti vaizdų glaudinimo biblioteką.
const imageData = shape.getImageData().toStream();
// ...
// Suspausti vaizdą ir nustatykite jį atgal į formą.
shape.getImageData().setImage(compressedImageBuffer);
}
}
var saveOptions = new aw.Saving.OoxmlSaveOptions()
saveOptions.compressionLevel = aw.Saving.CompressionLevel.Maximum
doc.save("Output.jpg", saveOptions)
const aw = require('@aspose/words');
var doc = new aw.Document()
var builder = new aw.DocumentBuilder(doc)
shape = builder.insertImage("Input.jpg")
var saveOptions = new aw.Saving.ImageSaveOptions(aw.SaveFormat.Jpeg)
saveOptions.jpegQuality = 50
shape.getShapeRenderer().save("Output.jpg", saveOptions)
We host our Node.js via .Net packages in NPM repositories. Please follow the step-by-step instructions on how to install "Aspose.Words for Node.js via .NET" to your developer environment.
This package is compatible with Node.js 14.17.0 or higher.
Galite optimizuoti daugelio kitų failų formatų failus: