Iki minangka solusi profesional kanggo ngoptimalake lan ngompres JPG ing C++. Gunakake C++ kanggo maksimalake kacepetan optimasi/komprèsi JPG. Coba online gratis!
Nggawe file JPG gedhe luwih cilik tanpa mundhut kualitas. Mbusak data sing ora perlu lan ora digunakake. Nyilikake ukuran file JPG ing kode. Pustaka C++ nyedhiyakake pangembang API terpadu kanggo ngoptimalake isi JPG.
Perpustakaan C++ minangka solusi mandiri lan ora mbutuhake piranti lunak pihak katelu sing diinstal.
Kompresi lossless lan optimasi isi jero digawe gampang karo 'Aspose.Words for C++'. Conto ing ngisor iki nuduhake carane ngoptimalake isi file JPG ing C++:
dotnet add package Aspose.Words.Cpp
Nyalin
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto shape = builder->InsertImage(u"Input.jpg");
auto saveOptions = MakeObject<ImageSaveOptions>(SaveFormat::Jpeg);
saveOptions->set_JpegQuality(50);
shape->GetShapeRenderer()->Save(u"Output.jpg", saveOptions);
using namespace Aspose::Words;
auto doc = MakeObject<Document>(u"Input.jpg");
doc->Cleanup();
auto nodes = doc->GetChildNodes(NodeType::Shape, true);
for (const auto& shape : System::IterateOver<Shape>(nodes))
{
if (shape->get_HasImage())
{
// Iku nganti pangembang kanggo milih perpustakaan kanggo komprèsi gambar.
auto image =
System::Drawing::Image::FromStream(shape->get_ImageData()->ToStream());
// ...
// Compress gambar lan nyetel maneh menyang wangun.
shape->get_ImageData()->SetImage("yourCompressedImage");
}
}
auto saveOptions = MakeObject<PdfSaveOptions>();
saveOptions->set_CacheBackgroundGraphics(true);
doc->Save(u"Output.jpg", saveOptions);
using namespace Aspose::Words;
auto doc = MakeObject<Document>(u"Input.jpg");
doc->Cleanup();
auto nodes = doc->GetChildNodes(NodeType::Shape, true);
for (const auto& shape : System::IterateOver<Shape>(nodes))
{
if (shape->get_HasImage())
{
// Terserah pangembang kanggo milih perpustakaan kanggo kompresi gambar.
auto image = System::Drawing::Image::Fromstream(shape->get_ImageData()->ToStream());
// ...
// Kompres gambar lan setel maneh menyang wangun.
shape->get_ImageData()->SetImage("yourCompressedImage");
}
}
doc->Save(u"Output.jpg");
using namespace Aspose::Words;
auto doc = MakeObject<Document>(u"Input.jpg");
doc->Cleanup();
auto nodes = doc->GetChildNodes(NodeType::Shape, true);
for (const auto& shape : System::IterateOver<Shape>(nodes))
{
if (shape->get_HasImage())
{
// Iku nganti pangembang kanggo milih perpustakaan kanggo komprèsi gambar.
auto image =
System::Drawing::Image::FromStream(shape->get_ImageData()->ToStream());
// ...
// Compress gambar lan nyetel maneh menyang wangun.
shape->get_ImageData()->SetImage("yourCompressedImage");
}
}
auto saveOptions = MakeObject<OoxmlSaveOptions>();
saveOptions->set_CompressionLevel(CompressionLevel::Maximum);
doc->Save(u"Output.jpg", saveOptions);
using namespace Aspose::Words;
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
auto shape = builder->InsertImage(u"Input.jpg");
auto saveOptions = MakeObject<ImageSaveOptions>(SaveFormat::Jpeg);
saveOptions->set_JpegQuality(50);
shape->GetShapeRenderer()->Save(u"Output.jpg", saveOptions);
Ana telung opsi kanggo nginstal Aspose.Words for C++ kanggo lingkungan pangembang. Pilih salah siji sing cocog karo kabutuhan sampeyan lan tindakake pandhuan langkah demi langkah:
Sampeyan bisa nggunakake perpustakaan C++ iki kanggo nggawe piranti lunak ing Microsoft Windows, Linux lan macOS:
Yen sampeyan nggawe piranti lunak kanggo Linux utawa macOS, priksa informasi babagan katergantungan perpustakaan tambahan (fontconfig lan paket sumber terbuka mesa-glu) ing Dokumentasi Produk.
Sampeyan bisa ngoptimalake file ing akeh format file liyane: