Convert Image to JPG in PHP

Load an image and save it in JPEG format with Aspose.Slides for PHP via Java.

Convert Image to JPG using PHP

To convert an image to JPG, load it with Images::fromFile, save it with ImageFormat::Jpeg, and dispose of it when you are done.

PHP code for converting Image into JPG

$image = Images::fromFile("input.png");
try {
    $image->save("output.jpg", ImageFormat::Jpeg);
} finally {
    $image->dispose();
}

Convert Image to JPG in PHP

Aspose.Slides for PHP via Java can load an image file and save it in JPEG format, keeping the image’s width and height.

The image API uses Images::fromFile to load the source image, save to write it, and ImageFormat::Jpeg to select JPEG output.

How to convert Image to JPG using Aspose.Slides for PHP API

These are the steps to convert Image to JPG in PHP.

  1. Install Aspose.Slides for PHP via Java.
  2. Configure Aspose.Slides in your PHP project.
  3. Load the source image with Images::fromFile.
  4. Save the image with save and ImageFormat::Jpeg, then call dispose to release it.

Built with Aspose.Slides

Convert Image to JPG Online

The free Aspose.Slides Conversion app is built with Aspose.Slides for PHP via Java, the same API as the code above. Open it and see what the API can do with your own Image files.

  • Runs in your browser, nothing to install.
  • See how Aspose.Slides converts files before you write code.
  • Upload Image files and save them as JPG.
  • Download the result or convert more files.

Convert Image To Other Supported Formats

You can also convert Image and save to other file formats. See all supported formats below: