public static function run($dataDir = null)
 {
     # initialize barcode reader
     $img = $dataDir . "barcode.jpg";
     $barcode_reader_type = new BarCodeReadType();
     $reader = new BarCodeReader($img, $barcode_reader_type->Code39Standard);
     # Try to recognize all possible barcodes in the image
     while (java_values($reader->read())) {
         # Display the symbology type
         print "BarCode Type: " . (string) $reader->getReadType() . PHP_EOL;
         # Display the codetext
         print "BarCode CodeText: " . (string) $reader->getCodeText() . PHP_EOL;
         # Get the barcode region
         $region = $reader->getRegion();
         if ($region != null) {
             # Initialize an object of type BufferedImage to get the Graphics object
             $imageIO = new ImageIO();
             //                $file=new File();
             $bufferedImage = $imageIO->read(new File($img));
             # Initialize graphics object from the image
             $g = $bufferedImage->getGraphics();
             $color = new Color();
             # Initialize paint object
             $p = new GradientPaint(0, 0, $color->red, 100, 100, $color->pink, true);
             $region->drawBarCodeEdges($g, $color->RED);
             # Save the image
             $imageIO->write($bufferedImage, "png", new File($dataDir . "Code39StdOut.png"));
         }
     }
     # Close reader
     $reader->close();
 }
示例#2
0
 public static function create_thumbnail_of_user_defined_window($dataDir = null)
 {
     # Instantiate Presentation class that represents the presentation file
     $pres = new Presentation($dataDir . 'demo.pptx');
     # Access the first slide
     $slide = $pres->getSlides()->get_Item(0);
     # Create a full scale image
     $image = $slide->getThumbnail(1, 1);
     # Getting the image of desired window inside generated slide thumnbnail
     # BufferedImage window = image.getSubimage(windowX, windowY, windowsWidth, windowHeight);
     $window_image = $image->getSubimage(100, 100, 200, 200);
     # Save the image to disk in JPEG format
     $imageIO = new ImageIO();
     $imageIO->write($image, "jpeg", new File($dataDir . "ContentBG_tnail.jpg"));
     print "Created thumbnail of user defined window, please check the output file." . PHP_EOL;
 }
示例#3
0
 public static function run($dataDir = null)
 {
     $pres = new Presentation();
     # Get the first slide
     $sld = $pres->getSlides()->get_Item(0);
     # Define co lumns with widths and rows with heights
     $dbl_cols = [150, 150, 150, 150];
     $dbl_rows = [100, 100, 100, 100, 90];
     # Add table shape to slide
     $tbl = $sld->getShapes()->addTable(50, 50, $dbl_cols, $dbl_rows);
     # Creating a Buffered Image object to hold the image file
     $imageIO = new ImageIO();
     $image = $imageIO->read(new File($dataDir . "aspose-logo.jpg"));
     $imgx1 = $pres->getImages()->addImage($image);
     $fillType = new FillType();
     $pictureFillMode = new PictureFillMode();
     $tbl->get_Item(0, 0)->getFillFormat()->setFillType($fillType->Picture);
     $tbl->get_Item(0, 0)->getFillFormat()->getPictureFillFormat()->setPictureFillMode($pictureFillMode->Stretch);
     $tbl->get_Item(0, 0)->getFillFormat()->getPictureFillFormat()->getPicture()->setImage($imgx1);
     # Write the presentation as a PPTX file
     $save_format = new SaveFormat();
     $pres->save($dataDir . "AddImage.pptx", $save_format->Pptx);
     print "Added image, please check the output file." . PHP_EOL;
 }