/** * Convert Image Format. * * @param string $inputPath Input file path. * @param string $outputFormat Output file format. * * @return string Returns the file path. * @throws Exception */ public function convertLocalFile($inputPath, $outputFormat) { //check whether files are set or not if ($inputPath == '') { throw new Exception('Input file not specified'); } if ($outputFormat == '') { throw new Exception('Format not specified'); } //build URI $strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/saveAs?format=' . $outputFormat; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::uploadFileBinary($signedURI, $inputPath, 'xml', 'POST'); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { if ($outputFormat == 'html') { $saveFormat = 'zip'; } else { $saveFormat = $outputFormat; } $outputFilename = Utils::getFileName($inputPath) . '.' . $saveFormat; Utils::saveFile($responseStream, AsposeApp::$outPutLocation . $outputFilename); return $outputFilename; } else { return $v_output; } }
public function uploadFile($strFile, $strFolder, $storageName = '') { $strRemoteFileName = basename($strFile); $strURIRequest = $this->strURIFile; if ($strFolder == '') { $strURIRequest .= $strRemoteFileName; } else { $strURIRequest .= $strFolder . '/' . $strRemoteFileName; } if ($storageName != '') { $strURIRequest .= '?storage=' . $storageName; } $signedURI = Utils::sign($strURIRequest); Utils::uploadFileBinary($signedURI, $strFile); }
/** * Convert a document to SaveFormat without using Aspose storage. * * @param string $inputPath The path of source file. * @param string $outputPath Path where you want to file after conversion. * @param string $outputFormat New file format. * * @return string Returns the file path. */ public function convertLocalFile($inputPath, $outputPath, $outputFormat) { $str_uri = Product::$baseProductUri . '/words/convert?format=' . $outputFormat; $signed_uri = Utils::sign($str_uri); $responseStream = Utils::uploadFileBinary($signed_uri, $inputPath, 'xml'); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { if ($outputFormat == 'html') { $saveFormat = 'zip'; } else { $saveFormat = $outputFormat; } if ($outputPath == '') { $outputPath = AsposeApp::$outPutLocation . Utils::getFileName($inputPath) . '.' . $saveFormat; } Utils::saveFile($responseStream, $outputPath); return $outputPath; } else { return $v_output; } }
public function convertLocalFile($inputFile = '', $outputFilename = '', $outputFormat = '') { //check whether file is set or not if ($inputFile == '') { throw new Exception('No file name specified'); } if ($outputFormat == '') { throw new Exception('output format not specified'); } $strURI = Product::$baseProductUri . '/pdf/convert?format=' . $outputFormat; if (!file_exists($inputFile)) { throw new Exception('input file doesnt exist.'); } $signedURI = Utils::sign($strURI); $responseStream = Utils::uploadFileBinary($signedURI, $inputFile, 'xml'); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { if ($outputFormat == 'html') { $saveFormat = 'zip'; } else { $saveFormat = $outputFormat; } if ($outputFilename == '') { $outputFilename = Utils::getFileName($inputFile) . '.' . $saveFormat; } $outputPath = AsposeApp::$outPutLocation . $outputFilename; Utils::saveFile($responseStream, $outputPath); return $outputPath; } else { return $v_output; } }
/** * Update PSD Image Properties without storage. * * @param integer $channelsCount Count of channels. * @param string $compression Compression method. * @param string $outPath Name of the output file. * * @return string Returns the file path. * @throws Exception */ public function updatePSDPropertiesFromLocalFile($inputPath, $channelsCount, $compression, $outPath) { if ($channelsCount == '') { throw new Exception('Channels count not specified'); } if ($compression == '') { throw new Exception('Compression method not specified'); } if ($outPath == '') { throw new Exception('Output file name not specified'); } //build URI $strURI = Product::$baseProductUri . '/imaging/psd?channelsCount=' . $channelsCount . '&compression=' . $compression . '&outPath=' . $outPath; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::uploadFileBinary($signedURI, $inputPath, 'xml', 'POST'); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { $folder = new Folder(); $outputStream = $folder->GetFile($outPath); $outputPath = AsposeApp::$outPutLocation . $outPath; Utils::saveFile($outputStream, $outputPath); return $outputPath; } else { return $v_output; } }
/** * Resize Image without Storage. * * @param integer $backgroundColorIndex Index of the background color. * @param integer $pixelAspectRatio Pixel aspect ratio. * @param boolean $interlaced Specifies if image is interlaced. * @param string $outPath Name of the output file. * * @return string Returns the file path. * @throws Exception */ public function resizeImage($inputPath, $newWidth, $newHeight, $outputFormat) { //check whether files are set or not if ($inputPath == '') { throw new Exception('Base file not specified'); } if ($newWidth == '') { throw new Exception('New image width not specified'); } if ($newHeight == '') { throw new Exception('New image height not specified'); } if ($outputFormat == '') { throw new Exception('Format not specified'); } //build URI $strURI = Product::$baseProductUri . '/imaging/resize?newWidth=' . $newWidth . '&newHeight=' . $newHeight . '&format=' . $outputFormat; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::uploadFileBinary($signedURI, $inputPath, 'xml', 'POST'); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { if ($outputFormat == 'html') { $saveFormat = 'zip'; } else { $saveFormat = $outputFormat; } $outputFilename = Utils::getFileName($inputPath) . '.' . $saveFormat; Utils::saveFile($responseStream, AsposeApp::$outPutLocation . $outputFilename); return $outputFilename; } else { return $v_output; } }
/** * Convert file into specified format without using Aspose cloud storage. * @param string $inputFile Path of the source file. * @param string $outputFile Name of the output file. * @param string $saveFormat Returns document in the specified format. * * @return string Returns the file path. * @throws Exception */ public function convertLocalFile($inputFile, $outputFile, $saveFormat) { if ($inputFile == '') { throw new Exception('Please Specify Input File Name along with path'); } if ($outputFile == '') { throw new Exception('Please Specify Output File Name along with Extension'); } if ($saveFormat == '') { throw new Exception('Please Specify a Save Format'); } $strURI = Product::$baseProductUri . '/cells/convert?format=' . $saveFormat; $signedURI = Utils::sign($strURI); if (!file_exists($inputFile)) { throw new Exception('Input File Doesnt Exists'); } $responseStream = Utils::uploadFileBinary($signedURI, $inputFile, 'xml'); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { if ($saveFormat == 'html') { $outputFormat = 'zip'; } else { $outputFormat = $saveFormat; } if ($outputFile == '') { $outputFileName = Utils::getFileName($inputFile) . '.' . $outputFormat; } else { $outputFileName = Utils::getFileName($outputFile) . '.' . $outputFormat; } Utils::saveFile($responseStream, AsposeApp::$outPutLocation . $outputFileName); return $outputFileName; } else { return $v_output; } }
/** * Convert a document to SaveFormat without using Aspose storage. * * @param string $inputPath The path of source file. * @param string $outputFile Path where you want to file after conversion. * @param string $saveFormat New file format. * * @return string|boolean Return the file path. * @throws Exception */ public function convertLocalFile($inputPath, $outputFile, $saveFormat) { if ($inputPath == '') { throw new Exception('Please specify input file'); } if ($outputFile == '') { throw new Exception('Please specify output file'); } if ($saveFormat == '') { throw new Exception('Please specify save format'); } $strURI = Product::$baseProductUri . '/slides/convert?format=' . $saveFormat; $signedURI = Utils::sign($strURI); $responseStream = Utils::uploadFileBinary($signedURI, $inputPath, 'xml'); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { if ($saveFormat == 'html') { $outputFormat = 'zip'; } else { $outputFormat = $saveFormat; } $outputFileName = Utils::getFileName($outputFile) . '.' . $outputFormat; Utils::saveFile($responseStream, AsposeApp::$outPutLocation . $outputFileName); return $outputFileName; } else { return $v_output; } }