Skip to content

Commit

Permalink
Merge pull request #6 from fahadadeel/master
Browse files Browse the repository at this point in the history
Aspose.Imaging Java for PHP Examples
  • Loading branch information
AdeelIlyas2014 committed Dec 10, 2015
2 parents 425a336 + 0e09f39 commit 997c9ed
Show file tree
Hide file tree
Showing 87 changed files with 1,755 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Plugins/Aspose_Imaging_Java_for_PHP/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Aspose.Imaging Java for PHP
Aspose Imaging Java for PHP is a PHP project that demonstrates / provides the Aspose.Imaging for Java API usage examples in PHP by using PHP/JAVA Bridge.

You will need to configure PHP/Java Bridge before using any of the Aspose provided Java APIs in PHP e.g Aspose.Imaging, Aspose.Cells and Aspose.Slides etc.

For the configuration/setup of PHP/Java Bridge, please see:

http://php-java-bridge.sourceforge.net/pjb/index.php

To download Aspose.Imaging for Java API to be used with these examples through PHP/Java Bridge
Please navigate to:

http://www.aspose.com/community/files/72/java-components/aspose.imaging-for-java/

For most complete documentation of the project, check Aspose.Imaging Java for PHP confluence wiki link:

http://www.aspose.com/docs/display/imagingjava/2.+Aspose.Imaging+Java+For+PHP

21 changes: 21 additions & 0 deletions Plugins/Aspose_Imaging_Java_for_PHP/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "asposeimaging/aspose_imaging_java_for_php",
"description": "Aspose Imaging Java Examples for PHP Developers. Helps you understand how to use Aspose.Imaging Java classes in your PHP Projects.",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Fahad Adeel",
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"require": {
"php": ">=5.3.0"
},
"autoload": {
"psr-4": {
"Aspose\\Imaging\\": "src/aspose/imaging"
}
}
}
20 changes: 20 additions & 0 deletions Plugins/Aspose_Imaging_Java_for_PHP/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
namespace Aspose\Imaging\ConvertingMetafilestoOtherImageFormats;

use com\aspose\imaging\fileformats\metafile\EmfMetafileImage as EmfMetafileImage;
use com\aspose\imaging\imageoptions\BmpOptions as BmpOptions;
use com\aspose\imaging\imageoptions\JpegOptions as JpegOptions;
use com\aspose\imaging\imageoptions\PngOptions as PngOptions;
use com\aspose\imaging\imageoptions\GifOptions as GifOptions;
use com\aspose\imaging\imageoptions\TiffOptions as TiffOptions;
use com\aspose\imaging\fileformats\tiff\enums\TiffExpectedFormat as TiffExpectedFormat;

class ConvertMetafileToOtherFormats{

public static function run($dataDir=null){

# Load a Metafile in an instance of EmfMetafileImage class
$metafile = new EmfMetafileImage($dataDir . "sample1.emf");

# Save EMF to BMP using BmpOptions object
$metafile->save($dataDir . "EmfToBmp.bmp", new BmpOptions());

# Save EMF to JPG using JpegOptions object
$metafile->save($dataDir . "EmfToJpg.jpg", new JpegOptions());

# Save EMF to PNG using PngOptions object
$metafile->save($dataDir . "EmfToPng.png", new PngOptions());

# Save EMF to GIF using GifOptions object
$metafile->save($dataDir . "EmfToGif.gif", new GifOptions());

# Save EMF to TIFF using TiffOptions object with default settings
$tiffExpectedFormat=new TiffExpectedFormat();
$metafile->save($dataDir . "EmfToTiff.tiff", new TiffOptions($tiffExpectedFormat->Default));

# Display Status.
print "Converted EMF to BMP, JPEG, PNG, GIF and TIFF formats successfully!".PHP_EOL;
}

}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
namespace Aspose\Imaging\ConvertingMetafilestoOtherImageFormats;

use com\aspose\imaging\Image as Image;
use com\aspose\imaging\Rectangle as Rectangle;
class CropMetafile{

public static function run($dataDir=null){

# Load an existing image in an instance of Image class
$image=new Image();
$image = $image->load($dataDir . "sample1.emf");

# Create an instance of Rectangle class with desired size
$rectangle = new Rectangle(10, 10, 100, 100);

# Perform the crop operation on object of Rectangle class
$image->crop($rectangle);

# Save the result in PNG format
$image->save($dataDir . "CropMetafile.png");

# Display Status.
print "Saved crop emf image to PNG successfully!".PHP_EOL;
}

}
?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
namespace Aspose\Imaging\DrawingImages;

use com\aspose\imaging\imageoptions\BmpOptions as BmpOptions;
use com\aspose\imaging\sources\StreamSource as StreamSource;
use com\aspose\imaging\Image as Image;
use com\aspose\imaging\Color as Color;
use com\aspose\imaging\Pen as Pen;
use com\aspose\imaging\Graphics as Graphics;

use java\io\ByteArrayInputStream as ByteArrayInputStream;
class DrawingArc{

public static function run($dataDir=null){

# Create an instance of BmpOptions and set its various properties
$create_options = new BmpOptions();
$create_options->setBitsPerPixel(32);

# Define the source property for the instance of BmpOptions
$ary=array();
$create_options->setSource(new StreamSource(new ByteArrayInputStream($ary)));

# Create an instance of Image
$image=new Image();
$image = $image->create($create_options,100,100);

# Create an instance of Color
$color = new Color();

# Create an instance of Pen
$pen = new Pen();

# Create and initialize an instance of Graphics class
$graphic = new Graphics($image);

# Clear the image surface with Yellow color
$graphic->clear($color->getYellow());

# Draw arc to screen.
$graphic->drawArc(new Pen($color->getBlack()), 0, 0, 100, 200, 45, 270);

# Save all changes.
$image->save($dataDir . "DrawArcExample.bmp");
print "Arc have been drawn in image successfully!".PHP_EOL;
}
}
?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
namespace Aspose\Imaging\DrawingImages;

use com\aspose\imaging\imageoptions\BmpOptions as BmpOptions;
use com\aspose\imaging\sources\StreamSource as StreamSource;
use com\aspose\imaging\Image as Image;
use com\aspose\imaging\Color as Color;
use com\aspose\imaging\Pen as Pen;
use com\aspose\imaging\Graphics as Graphics;
use com\aspose\imaging\brushes\SolidBrush as SolidBrush;
use com\aspose\imaging\Rectangle as Rectangle;

use java\io\ByteArrayInputStream as ByteArrayInputStream;
class DrawingEllipse{

public static function run($dataDir=null){

# Create an instance of BmpOptions and set its various properties
$create_options = new BmpOptions();
$create_options->setBitsPerPixel(32);

# Define the source property for the instance of BmpOptions
$ary=array();
$create_options->setSource(new StreamSource(new ByteArrayInputStream($ary)));

# Create an instance of Image
$image=new Image();
$image = $image->create($create_options,100,100);

# Create an instance of Color
$color = new Color();

# Create an instance of Pen
$pen = new Pen();

# Create and initialize an instance of Graphics class
$graphic = new Graphics($image);

# Clear the image surface with Yellow color
$graphic->clear($color->getYellow());

$solid_brush = new SolidBrush();
$rectangle = new Rectangle();

# Draw a dotted ellipse shape by specifying the Pen object having red color and a surrounding Rectangle
$graphic->drawEllipse(new Pen($color->getRed()), new Rectangle(30, 10, 40, 80));

# Draw a continuous ellipse shape by specifying the Pen object having solid brush with blue color and a surrounding Rectangle
$graphic->drawEllipse(new Pen(new SolidBrush($color->getBlue())), new Rectangle(10, 30, 80, 40));

# Save all changes.
$image->save($dataDir . "DrawEllipseExample.bmp");

print "Ellipse have been drawn in image successfully!".PHP_EOL;
}

}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
namespace Aspose\Imaging\DrawingImages;

use com\aspose\imaging\imageoptions\BmpOptions as BmpOptions;
use com\aspose\imaging\sources\FileCreateSource as FileCreateSource;
use com\aspose\imaging\Image as Image;
use com\aspose\imaging\Color as Color;

class DrawingImagesUsingCoreFunctionality{

public static function run($dataDir=null){

# Create an instance of BmpOptions and set its various properties
$create_options = new BmpOptions();
$create_options->setBitsPerPixel(24);

# Create an instance of FileCreateSource and assign it to Source property
$fileCreateSource=new FileCreateSource();
$create_options->setSource(new FileCreateSource($dataDir . "sample.bmp",false));

# Create an instance of RasterImage
$image=new Image();
$raster_image = $image->create($create_options,500,500);

# Get the pixels of the image by specifying the area as image boundary
$pixels = $raster_image->loadPixels($raster_image->getBounds());

$index = 0;
while ($index < sizeof($pixels)) {
# Set the indexed pixel color to yellow
$color = new Color();
$pixels[$index] = $color->getYellow();
$index += 1;
}
$raster_image->savePixels($raster_image->getBounds(), $pixels);

# save all changes
$raster_image->save();

print "Draw Images Using Core Functionality.".PHP_EOL;
}
}
?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
namespace Aspose\Imaging\DrawingImages;

use com\aspose\imaging\imageoptions\BmpOptions as BmpOptions;
use com\aspose\imaging\sources\FileCreateSource as FileCreateSource;
use com\aspose\imaging\Image as Image;
use com\aspose\imaging\Graphics as Graphics;
use com\aspose\imaging\Color as Color;
use com\aspose\imaging\Pen as Pen;
use com\aspose\imaging\Rectangle as Rectangle;

class DrawingImagesUsingGraphics{

public static function run($dataDir=null){


# Create an instance of BmpOptions and set its various properties
$create_options = new BmpOptions();
$create_options->setBitsPerPixel(24);

# Create an instance of FileCreateSource and assign it to Source property
$create_options->setSource(new FileCreateSource($dataDir . "DrawingImageUsingGraphics.bmp",false));

# Create an instance of Image
$image=new Image();
$image = $image->create($create_options,500,500);

# Create and initialize an instance of Graphics
$graphics = new Graphics($image);

# Clear the image surface with white color
$color=new Color();
$graphics->clear($color->getWhite());

# Create and initialize a Pen object with blue color
$pen = new Pen($color->getBlue());

# Draw Ellipse by defining the bounding rectangle of width 150 and height 100
$graphics->drawEllipse($pen, new Rectangle(10, 10, 150, 100));

# save all changes
$image->save();
print "Created image using graphics.".PHP_EOL;
}
}
Loading

0 comments on commit 997c9ed

Please sign in to comment.