├── Examples ├── .gitignore ├── README.md ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── aspose │ │ └── psd │ │ └── examples │ │ ├── Conversion │ │ ├── ApplyGausWienerFilters.java │ │ ├── ApplyGausWienerFiltersForColorImage.java │ │ ├── ApplyMedianAndWienerFilters.java │ │ ├── ApplyMotionWienerFilters.java │ │ ├── BinarizationWithFixedThreshold.java │ │ ├── BinarizationWithOtsuThreshold.java │ │ ├── BradleyThreshold.java │ │ ├── CMYKPSDtoCMYKTiff.java │ │ ├── ColorConversionUsingDefaultProfiles.java │ │ ├── ColorConversionUsingICCProfiles.java │ │ ├── CropPSDFile.java │ │ ├── CroppingPSDWhenConvertingToPNG.java │ │ ├── ExportImagesinMultiThreadEnv.java │ │ ├── GIFImageLayersToTIFF.java │ │ ├── GrayScaling.java │ │ ├── LoadingFromStream.java │ │ ├── PSDToRasterImageFormats.java │ │ ├── RenderTextWithDifferentColorsInTextLayer.java │ │ ├── SaveImageWorker.java │ │ ├── SavingToDisk.java │ │ ├── SavingToStream.java │ │ ├── SettingForReplacingMissingFonts.java │ │ ├── SupportForInterruptMonitor.java │ │ └── SyncRoot.java │ │ ├── DrawingAndFormattingImages │ │ ├── AddEffectAtRunTime.java │ │ ├── AdjustingBrightness.java │ │ ├── AdjustingContrast.java │ │ ├── AdjustingGamma.java │ │ ├── BlurAnImage.java │ │ ├── ColorOverlayEffect.java │ │ ├── CombiningImages.java │ │ ├── CreateXMPMetadata.java │ │ ├── CreatingBySettingPath.java │ │ ├── CreatingUsingStream.java │ │ ├── CroppingByRectangle.java │ │ ├── CroppingByShifts.java │ │ ├── DitheringForRasterImages.java │ │ ├── ExpandAndCropImages.java │ │ ├── FontReplacement.java │ │ ├── ForceFontCache.java │ │ ├── ImplementBicubicResampler.java │ │ ├── ImplementLossyGIFCompressor.java │ │ ├── InvertAdjustmentLayer.java │ │ ├── RenderingColorEffect.java │ │ ├── RenderingDropShadow.java │ │ ├── ResizeImageProportionally.java │ │ ├── ResizingWithResizeTypeEnumeration.java │ │ ├── RotatingAnImage.java │ │ ├── RotatingAnImageOnASpecificAngle.java │ │ ├── SimpleDrawing.java │ │ ├── SimpleResizing.java │ │ ├── SupportBlendModes.java │ │ ├── SupportShadowEffect.java │ │ └── VerifyImageTransparency.java │ │ ├── DrawingImages │ │ ├── AddGradientEffects.java │ │ ├── AddNewRegularLayerToPSD.java │ │ ├── AddPatternEffects.java │ │ ├── AddSignatureToImage.java │ │ ├── AddStrokeLayerColor.java │ │ ├── AddStrokeLayerGradient.java │ │ ├── AddStrokeLayerPattern.java │ │ ├── CoreDrawingFeatures.java │ │ ├── DrawingArc.java │ │ ├── DrawingBezier.java │ │ ├── DrawingEllipse.java │ │ ├── DrawingLines.java │ │ ├── DrawingRectangle.java │ │ ├── DrawingUsingGraphics.java │ │ └── DrawingUsingGraphicsPath.java │ │ ├── Licensing │ │ └── MeteredLicensing.java │ │ ├── ModifyingAndConvertingImages │ │ ├── AI │ │ │ ├── AIToGIF.java │ │ │ ├── AIToJPG.java │ │ │ ├── AIToPDF.java │ │ │ ├── AIToPNG.java │ │ │ ├── AIToPSD.java │ │ │ └── AIToTIFF.java │ │ ├── JPEG │ │ │ ├── AddThumbnailToEXIFSegment.java │ │ │ ├── AddThumbnailToJFIFSegment.java │ │ │ ├── AutoCorrectOrientationOfJPEGImages.java │ │ │ ├── ColorTypeAndCompressionType.java │ │ │ ├── ExtractThumbnailFromJFIF.java │ │ │ ├── ExtractThumbnailFromPSD.java │ │ │ ├── ReadAllEXIFTagList.java │ │ │ ├── ReadAllEXIFTags.java │ │ │ ├── ReadSpecificEXIFTagsInformation.java │ │ │ ├── ReadandModifyJpegEXIFTags.java │ │ │ ├── SupportFor2And7BitsJPEG.java │ │ │ ├── SupportForJPEGLSWithCMYK.java │ │ │ └── WritingAndModifyingEXIFData.java │ │ ├── PNG │ │ │ ├── ApplyFilterMethod.java │ │ │ ├── ChangeBackgroundColor.java │ │ │ ├── CompressingFiles.java │ │ │ ├── SettingResolution.java │ │ │ ├── SpecifyBitDepth.java │ │ │ └── SpecifyTransparency.java │ │ ├── PSB │ │ │ ├── PSBToJPG.java │ │ │ ├── PSBToPDF.java │ │ │ └── PSBToPSD.java │ │ ├── PSD │ │ │ ├── AddChannelMixerAdjustmentLayer.java │ │ │ ├── AddCurvesAdjustmentLayer.java │ │ │ ├── AddDiagnolWatermark.java │ │ │ ├── AddFillLayers.java │ │ │ ├── AddHueSaturationAdjustmentLayer.java │ │ │ ├── AddIopaResource.java │ │ │ ├── AddLevelAdjustmentLayer.java │ │ │ ├── AddTextLayerOnRuntime.java │ │ │ ├── AddWatermark.java │ │ │ ├── ChangeBlendModeInGradientOverlayEffect.java │ │ │ ├── ColorFillLayer.java │ │ │ ├── ColorReplacementInPSD.java │ │ │ ├── ControllCacheReallocation.java │ │ │ ├── CreateIndexedPSDFiles.java │ │ │ ├── CreateThumbnailsFromPSDFiles.java │ │ │ ├── DetectFlattenedPSD.java │ │ │ ├── ExportImageToPSD.java │ │ │ ├── ExportPSDLayerToRasterImage.java │ │ │ ├── FillOpacityOfLayers.java │ │ │ ├── FormatTextPortions.java │ │ │ ├── GradientFillLayer.java │ │ │ ├── GrayScaleSupportForAlpha.java │ │ │ ├── ImportImageToPSDLayer.java │ │ │ ├── LayerCreationDateTime.java │ │ │ ├── LayerEffectsForPSD.java │ │ │ ├── LoadImageToPSD.java │ │ │ ├── ManageBrightnessContrastAdjustmentLayer.java │ │ │ ├── ManageChannelMixerAdjusmentLayer.java │ │ │ ├── ManageExposureAdjustmentLayer.java │ │ │ ├── ManagePhotoFilterAdjustmentLayer.java │ │ │ ├── MergeOnePSDlayerToOther.java │ │ │ ├── MergePSDLayers.java │ │ │ ├── ModifyGradientOverlayEffect.java │ │ │ ├── PossibilityToFlattenLayers.java │ │ │ ├── RenderingExportOfChannelMixerAdjusmentLyer.java │ │ │ ├── RenderingExposureAdjustmentLayer.java │ │ │ ├── RenderingOfCurvesAdjustmentLayer.java │ │ │ ├── RenderingOfLevelAdjustmentLayer.java │ │ │ ├── RenderingOfRotatedTextLayer.java │ │ │ ├── SheetColorHighlighting.java │ │ │ ├── ShowProgressOnConversion.java │ │ │ ├── StrokeEffectWithColorFill.java │ │ │ ├── StyleTextPortions.java │ │ │ ├── SupportBorderInformationResource.java │ │ │ ├── SupportForInterruptMonitor.java │ │ │ ├── SupportForNvrtResource.java │ │ │ ├── SupportGrayscaleColorMode16Bit.java │ │ │ ├── SupportInnerShadowLayerEffect.java │ │ │ ├── SupportLayerForPSD.java │ │ │ ├── SupportLengthRecordDataProperties.java │ │ │ ├── SupportOfAdjusmentLayers.java │ │ │ ├── SupportOfClippingMask.java │ │ │ ├── SupportOfGdFlResource.java │ │ │ ├── SupportOfLayerMask.java │ │ │ ├── SupportOfLinkedLayer.java │ │ │ ├── SupportOfRGBColor.java │ │ │ ├── SupportOfRotateLayer.java │ │ │ ├── SupportOfSoCoResource.java │ │ │ ├── SupportOfVmskResource.java │ │ │ ├── SupportPatternFillLayerRendering.java │ │ │ ├── TextLayerBoundBox.java │ │ │ ├── UncompressedImageStreamObject.java │ │ │ ├── UncompressedImageUsingFile.java │ │ │ ├── UpdateTextLayerInPSDFile.java │ │ │ └── UseCustomRawDataLoader.java │ │ └── TIFF │ │ │ ├── CompressingTiff.java │ │ │ ├── TIFFWithAdobeDeflateCompression.java │ │ │ ├── TIFFWithDeflateCompression.java │ │ │ └── TiffOptionsConfiguration.java │ │ ├── Utils │ │ ├── Assert.java │ │ └── Utils.java │ │ └── WorkingWithPSD │ │ ├── ExportLayerGroupToImage.java │ │ ├── SupportForBlwhResource.java │ │ ├── SupportForClblResource.java │ │ ├── SupportForInfxResource.java │ │ └── SupportForLspfResource.java │ └── resources │ ├── 1_Output │ └── .gitignore │ ├── AI │ ├── 34992OStroke.ai │ ├── rect2_color.ai │ └── sample.ai │ ├── Conversion │ ├── 1.psd │ ├── CropTest.psd │ ├── ISOcoated_v2_FullGamut4.icc │ ├── big2.psb │ ├── big_out.png │ ├── eciRGB_v2.icc │ ├── export.bmp │ ├── export.gif │ ├── export.jp2 │ ├── export.jpeg │ ├── export.png │ ├── result.png │ └── sample.psd │ ├── DrawingAndFormattingImages │ ├── BlendModeColorBurn_Test100.png │ ├── BlendModeColorBurn_Test50.png │ ├── BlendModeColorDodge_Test100.png │ ├── BlendModeColorDodge_Test50.png │ ├── BlendModeColor_Test100.png │ ├── BlendModeColor_Test50.png │ ├── BlendModeDarken_Test100.png │ ├── BlendModeDarken_Test50.png │ ├── BlendModeDarkerColor_Test100.png │ ├── BlendModeDarkerColor_Test50.png │ ├── BlendModeDifference_Test100.png │ ├── BlendModeDifference_Test50.png │ ├── BlendModeDissolve_Test100.png │ ├── BlendModeDissolve_Test50.png │ ├── BlendModeDivide_Test100.png │ ├── BlendModeDivide_Test50.png │ ├── BlendModeExclusion_Test100.png │ ├── BlendModeExclusion_Test50.png │ ├── BlendModeHardLight_Test100.png │ ├── BlendModeHardLight_Test50.png │ ├── BlendModeHardMix_Test100.png │ ├── BlendModeHardMix_Test50.png │ ├── BlendModeHue_Test100.png │ ├── BlendModeHue_Test50.png │ ├── BlendModeLightenColor_Test100.png │ ├── BlendModeLightenColor_Test50.png │ ├── BlendModeLighten_Test100.png │ ├── BlendModeLighten_Test50.png │ ├── BlendModeLinearBurn_Test100.png │ ├── BlendModeLinearBurn_Test50.png │ ├── BlendModeLinearDodgeAdd_Test100.png │ ├── BlendModeLinearDodgeAdd_Test50.png │ ├── BlendModeLinearLight_Test100.png │ ├── BlendModeLinearLight_Test50.png │ ├── BlendModeLuminosity_Test100.png │ ├── BlendModeLuminosity_Test50.png │ ├── BlendModeMultiply_Test100.png │ ├── BlendModeMultiply_Test50.png │ ├── BlendModeNormal_Test100.png │ ├── BlendModeNormal_Test50.png │ ├── BlendModeOverlay_Test100.png │ ├── BlendModeOverlay_Test50.png │ ├── BlendModePinLight_Test100.png │ ├── BlendModePinLight_Test50.png │ ├── BlendModeSaturation_Test100.png │ ├── BlendModeSaturation_Test50.png │ ├── BlendModeScreen_Test100.png │ ├── BlendModeScreen_Test50.png │ ├── BlendModeSoftLight_Test100.png │ ├── BlendModeSoftLight_Test50.png │ ├── BlendModeSubtract_Test100.png │ ├── BlendModeSubtract_Test50.png │ ├── BlendModeVividLight_Test100.png │ ├── BlendModeVividLight_Test50.png │ ├── Cloud_AzPlat_Banner3A_SB_EN_US_160x600_chinese_font.psd │ ├── Color.psd │ ├── ColorDodge.psd │ ├── ColorOverlay.psd │ ├── ColorOverlayChanged.psd │ ├── ColorOverlayresult.png │ ├── Colorburn.psd │ ├── CreatingAnImageBySettingPath_out.psd │ ├── CroppingByRectangle_out.jpg │ ├── CroppingByShifts_out.jpg │ ├── Darken.psd │ ├── DarkerColor.psd │ ├── Difference.psd │ ├── Dissolve.psd │ ├── Divide.psd │ ├── Exclusion.psd │ ├── HardLight.psd │ ├── HardMix.psd │ ├── Hue.psd │ ├── InvertStripes_before.psd │ ├── Lighten.psd │ ├── LightenColor.psd │ ├── LinearBurn.psd │ ├── LinearDodgeAdd.psd │ ├── LinearLight.psd │ ├── Luminosity.psd │ ├── Multiply.psd │ ├── NoFont.psd │ ├── Normal.psd │ ├── OneLayer.psd │ ├── Overlay.psd │ ├── PinLight.psd │ ├── ResizingwithResizeTypeEnumeration_out.jpg │ ├── RotatingAnImage_out.jpg │ ├── RotatingImageOnSpecificAngle_out.jpg │ ├── SampleImage_out.bmp │ ├── Saturation.psd │ ├── Screen.psd │ ├── Shadow.psd │ ├── ShadowChanged.psd │ ├── Shadowchanged1.png │ ├── SimpleResizeImageProportionally_out.png │ ├── SimpleResizing_out.jpg │ ├── SoftLight.psd │ ├── Subtract.psd │ ├── ThreeRegularLayers.psd │ ├── ThreeRegularLayersChanged.psd │ ├── Two_images_result_out.psd │ ├── VividLight.psd │ ├── anim_lossy-200.gif │ ├── anim_lossy-80.gif │ ├── example1.psd │ ├── example2.psd │ ├── jpeg_out.jpg │ ├── replaced_font.png │ ├── sample.psd │ ├── sample_bicubic.psd │ └── sample_out.bmp │ ├── DrawingImages │ ├── AddSignatureToImage_out.png │ ├── Arc.bmp │ ├── Bezier.bmp │ ├── CoreDrawingFeatures.bmp │ ├── DrawingUsingGraphicsPath_output.psd │ ├── DrawingUsingGraphics_output.bmp │ ├── Ellipse.bmp │ ├── GradientOverlay.psd │ ├── GradientOverlayChanged.psd │ ├── Lines.bmp │ ├── OneLayer.psd │ ├── OneLayerEdited.png │ ├── OneLayerEdited.psd │ ├── PatternOverlay.psd │ ├── PatternOverlayChanged.psd │ ├── Rectangle.bmp │ ├── Stroke.psd │ ├── StrokeGradientChanged.psd │ ├── StrokePatternChanged.psd │ ├── layers.psd │ └── sample.psd │ ├── ModifyingAndConvertingImages │ ├── 0_out.png │ ├── 1280px-Zebras_Serengeti.psd │ ├── 1_out.png │ ├── 2_out.png │ ├── 3_out.png │ ├── 4_out.png │ ├── 5_out.png │ ├── 6_out.png │ ├── 7_out.png │ ├── 8_out.png │ ├── 9_out.png │ ├── ApplyFilterMethod_out.png │ ├── ChangeBackground_out.png │ ├── ChannelMixerAdjustmentLayerCmyk.psd │ ├── ChannelMixerAdjustmentLayerCmykChanged.psd │ ├── ChannelMixerAdjustmentLayerRgb.psd │ ├── ChannelMixerAdjustmentLayerRgbChanged.psd │ ├── CmykWithAlpha.psd │ ├── ColorFillLayer.psd │ ├── CurvesAdjustmentLayer.psd │ ├── ExportToMultiPageTiff_output.tif │ ├── LinkedLayerexample.psd │ ├── PsdImage.psd │ ├── SampleTiff_out.tiff │ ├── SettingResolution_output.png │ ├── SpecifyBitDepth_out.png │ ├── Specify_Transparency_result.png │ ├── TIFFwithAdobeDeflateCompression_output.tif │ ├── TIFFwithDeflateCompression_out.tiff │ ├── aspose_out.psd │ ├── layers.psd │ └── sample.psd │ ├── PSB │ ├── 2Layers.psb │ └── Simple.psb │ └── PSD │ ├── 1.psd │ ├── AddDiagnolWatermark_output.png │ ├── AddWatermark_output.png │ ├── Apple.psd │ ├── BlackWhiteAdjustmentLayerStripesMask.psd │ ├── BlackWhiteAdjustmentLayerStripesMask2.psd │ ├── BrightnessContrastModern.psd │ ├── BrightnessContrastModernChanged.psd │ ├── ChannelMixerAdjustmentLayer.psd │ ├── ChannelMixerAdjustmentLayerChanged.psd │ ├── ChannelMixerAdjustmentLayerCmyk.psd │ ├── ChannelMixerAdjustmentLayerCmykChanged.png │ ├── ChannelMixerAdjustmentLayerCmykChanged.psd │ ├── ChannelMixerAdjustmentLayerRgb.psd │ ├── ChannelMixerAdjustmentLayerRgbChanged.png │ ├── ChannelMixerAdjustmentLayerRgbChanged.psd │ ├── ClippingMaskComplex.png │ ├── ClippingMaskComplex.psd │ ├── CmykWithAlpha.psd │ ├── ColorFillLayer.psd │ ├── ColorFillLayer_output.psd │ ├── ComplexGradientFillLayer.psd │ ├── ComplexGradientFillLayer_after.psd │ ├── CreateThumbnailsFromPSDFiles_out_22.bmp │ ├── CurvesAdjustmentLayer.psd │ ├── CurvesAdjustmentLayer1.psd │ ├── CurvesAdjustmentLayerChanged1.png │ ├── CurvesAdjustmentLayerChanged1.psd │ ├── ExportImageToPSD_output.psd │ ├── ExportLayerGroupToImageSample.psd │ ├── ExposureAdjustmentLayer.psd │ ├── ExposureAdjustmentLayerChanged.psd │ ├── FillOpacitySample.psd │ ├── FillOpacitySampleChanged.psd │ ├── HueSaturationAdjustmentLayer.psd │ ├── HueSaturationAdjustmentLayerChanged.psd │ ├── ImportImageToPSDLayer_out.psd │ ├── InvertAdjustmentLayer.psd │ ├── LayerEffectsForPSD.png │ ├── LayerWithText.psd │ ├── LevelsAdjustmentLayer.psd │ ├── LevelsAdjustmentLayerChanged.png │ ├── LevelsAdjustmentLayerChanged.psd │ ├── LevelsAdjustmentLayerRgb.psd │ ├── LevelsAdjustmentLayerRgbChanged.psd │ ├── MaskComplex.png │ ├── MaskComplex.psd │ ├── MergePSDlayers_output.jpg │ ├── MergedLayersFromTwoDifferentPsd.psd │ ├── Newsample_out.psd │ ├── OneLayer.psd │ ├── PathOperationsShape.psd │ ├── PhotoExample.psd │ ├── PhotoExampleAddedExposure.psd │ ├── PhotoExampleAddedHueSaturation.psd │ ├── PhotoExampleAddedPhotoFilter.psd │ ├── PhotoFilterAdjustmentLayer.psd │ ├── PhotoFilterAdjustmentLayerChanged.psd │ ├── PsdExample.psd │ ├── Rectangle.psd │ ├── Rectangle_changed.psd │ ├── RotateFlipTest2617.png │ ├── RotateFlipTest2617.psd │ ├── SampleForClblResource.psd │ ├── SampleForInfxResource.psd │ ├── SampleForLspfResource.psd │ ├── SheetColorHighlightExample.psd │ ├── SheetColorHighlightExampleChanged.psd │ ├── StrokeComplex.psd │ ├── StrokeComplexRendering.png │ ├── StrokeComplexRendering.psd │ ├── SupportBorderInformationResource.psd │ ├── ThreeColorsParagraphs.psd │ ├── ThreeRegularLayersSemiTransparent.psd │ ├── ThreeRegularLayersSemiTransparentFlattened.psd │ ├── ThreeRegularLayersSemiTransparentFlattenedLayerByLayer.psd │ ├── TransformedText.psd │ ├── TransformedTextExport.png │ ├── TransformedTextExport.psd │ ├── argb16bit_5x5.psd │ ├── argb16bit_5x5_no_layers.psd │ ├── argb8bit_5x5.psd │ ├── argb8bit_5x5_no_layers.psd │ ├── asposeImage02.psd │ ├── big.psb │ ├── cmyk16bit_5x5_no_layers.psd │ ├── grayscale5x5.psd │ ├── inRgb16.psd │ ├── index8bit_5x5.psd │ ├── layers.png │ ├── layers.psd │ ├── outRgb16.jpg │ ├── outRgb16.psd │ ├── psdnet256.psd │ ├── psdnet585.psd │ ├── sample.psd │ ├── text212.psd │ ├── text_ethalon_different_colors.psd │ └── uncompressed_out.psd └── README.md /Examples/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ -------------------------------------------------------------------------------- /Examples/README.md: -------------------------------------------------------------------------------- 1 | ## Aspose.PSD for Java Examples 2 | 3 | This repository contains Java Example Project for [Aspose.PSD for Java](https://products.aspose.com/psd/java) which will help you learn Aspose.PSD for Java and write your own applications. 4 | 5 |

6 | 7 | 8 | 9 |

10 | 11 | 12 | ## How to Run the Examples? 13 | 14 | After you have downloaded the ZIP file from the [Download ZIP](https://github.com/aspose-psd/Aspose.PSD-for-Java/archive/master.zip) link above, please check the following link with detailed instructions on how to run these Source Code Examples. 15 | 16 | [How to Run the Examples](https://docs.aspose.com/display/psdjava/How+to+Run+the+Examples) 17 | 18 | Please feel free to contact us if you have any question, issue or suggestion. 19 | -------------------------------------------------------------------------------- /Examples/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | com.aspose 5 | psd-java-examples 6 | 1.0-SNAPSHOT 7 | jar 8 | 9 | UTF-8 10 | 1.8 11 | 1.8 12 | 13 | 14 | 15 | 16 | 17 | 18 | com.aspose 19 | aspose-psd 20 | 20.5 21 | javadoc 22 | 23 | 24 | 25 | com.aspose 26 | aspose-psd 27 | 20.5 28 | jdk16 29 | 30 | 31 | 32 | 33 | AsposeJavaAPI 34 | Aspose Java API 35 | https://repository.aspose.com/repo/ 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/Conversion/ApplyGausWienerFilters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.Conversion; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.RasterImage; 10 | import com.aspose.psd.examples.Utils.Utils; 11 | import com.aspose.psd.imagefilters.filteroptions.GaussWienerFilterOptions; 12 | import com.aspose.psd.imageoptions.GifOptions; 13 | 14 | 15 | public class ApplyGausWienerFilters { 16 | public static void main(String[] args) 17 | { 18 | //ExStart:ApplyGausWienerFilters 19 | String dataDir = Utils.getDataDir(ApplyGausWienerFilters.class) + "Conversion/"; 20 | 21 | String sourceFile = dataDir + "sample.psd"; 22 | String destName = dataDir + "gauss_wiener_out.gif"; 23 | 24 | 25 | Image image = Image.load(sourceFile); 26 | RasterImage rasterImage = (RasterImage)image ; 27 | if (rasterImage == null) 28 | { 29 | return; 30 | } 31 | // Create an instance of GaussWienerFilterOptions class and set the radius size and smooth value. 32 | GaussWienerFilterOptions options = new GaussWienerFilterOptions(12, 3); 33 | options.setGrayscale(true); 34 | 35 | // Apply MedianFilterOptions filter to RasterImage object and Save the resultant image 36 | rasterImage.filter(image.getBounds(), options); 37 | 38 | image.save(destName, new GifOptions()); 39 | 40 | //ExEnd:ApplyGausWienerFilters 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/Conversion/ApplyMedianAndWienerFilters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.Conversion; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.RasterImage; 10 | import com.aspose.psd.examples.Utils.Utils; 11 | import com.aspose.psd.imagefilters.filteroptions.MedianFilterOptions; 12 | import com.aspose.psd.imageoptions.GifOptions; 13 | 14 | /** 15 | * 16 | * 17 | */ 18 | public class ApplyMedianAndWienerFilters { 19 | public static void main(String[] args) 20 | { 21 | //ExStart:ApplyMedianAndWienerFilters 22 | String dataDir = Utils.getDataDir(ApplyMedianAndWienerFilters.class) + "Conversion/"; 23 | 24 | String sourceFile = dataDir + "sample.psd"; 25 | String destName = dataDir + "median_test_denoise_out.gif"; 26 | 27 | Image image = Image.load(sourceFile); 28 | // Cast the image into RasterImage 29 | RasterImage rasterImage = (RasterImage)image; 30 | if (rasterImage == null) 31 | { 32 | return; 33 | } 34 | 35 | // Create an instance of MedianFilterOptions class and set the size, Apply MedianFilterOptions filter to RasterImage object and Save the resultant image 36 | MedianFilterOptions options = new MedianFilterOptions(4); 37 | rasterImage.filter(image.getBounds(), options); 38 | image.save(destName, new GifOptions()); 39 | //ExEnd:ApplyMedianAndWienerFilters 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/Conversion/ApplyMotionWienerFilters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.Conversion; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.RasterImage; 10 | import com.aspose.psd.examples.Utils.Utils; 11 | import com.aspose.psd.imagefilters.filteroptions.MotionWienerFilterOptions; 12 | import com.aspose.psd.imageoptions.GifOptions; 13 | 14 | /** 15 | * 16 | * 17 | */ 18 | public class ApplyMotionWienerFilters { 19 | public static void main(String[] args) 20 | { 21 | //ExStart:ApplyMotionWienerFilters 22 | String dataDir = Utils.getDataDir(ApplyMotionWienerFilters.class) + "Conversion/"; 23 | 24 | String sourceFile = dataDir + "sample.psd"; 25 | String destName = dataDir + "motion_filter_out.gif"; 26 | 27 | Image image = Image.load(sourceFile); 28 | 29 | // Cast the image into RasterImage 30 | RasterImage rasterImage = (RasterImage)image; 31 | if (rasterImage == null) 32 | { 33 | return; 34 | } 35 | 36 | // Create an instance of MotionWienerFilterOptions class and set the length, smooth value and angle. 37 | MotionWienerFilterOptions options = new MotionWienerFilterOptions(50, 9, 90); 38 | options.setGrayscale(true); 39 | 40 | // Apply MedianFilterOptions filter to RasterImage object and Save the resultant image 41 | rasterImage.filter(image.getBounds(), options); 42 | image.save(destName, new GifOptions()); 43 | //ExEnd:ApplyMotionWienerFilters 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/Conversion/BinarizationWithFixedThreshold.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.Conversion; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.RasterCachedImage; 10 | import com.aspose.psd.examples.Utils.Utils; 11 | import com.aspose.psd.imageoptions.JpegOptions; 12 | 13 | /** 14 | * 15 | * 16 | */ 17 | public class BinarizationWithFixedThreshold { 18 | 19 | public static void main(String[] args) 20 | { 21 | //ExStart:BinarizationWithFixedThreshold 22 | String dataDir = Utils.getDataDir(BinarizationWithFixedThreshold.class) + "Conversion/"; 23 | 24 | String sourceFile = dataDir + "sample.psd"; 25 | String destName = dataDir + "BinarizationWithFixedThreshold_out.jpg"; 26 | 27 | Image image = Image.load(sourceFile); 28 | RasterCachedImage rasterCachedImage = (RasterCachedImage)image; 29 | if (!rasterCachedImage.isCached()) 30 | { 31 | // Cache image if not already cached 32 | rasterCachedImage.cacheData(); 33 | } 34 | 35 | // Binarize image with predefined fixed threshold and Save the resultant image 36 | rasterCachedImage.binarizeFixed((byte)100); 37 | rasterCachedImage.save(destName, new JpegOptions()); 38 | //ExEnd:BinarizationWithFixedThreshold 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/Conversion/BinarizationWithOtsuThreshold.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.Conversion; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.RasterCachedImage; 10 | import com.aspose.psd.examples.Utils.Utils; 11 | import com.aspose.psd.imageoptions.JpegOptions; 12 | 13 | /** 14 | * 15 | * 16 | */ 17 | public class BinarizationWithOtsuThreshold { 18 | public static void main(String[] args) 19 | { 20 | //ExStart:BinarizationWithOtsuThreshold 21 | String dataDir = Utils.getDataDir(BinarizationWithOtsuThreshold.class) + "Conversion/"; 22 | 23 | String sourceFile = dataDir + "sample.psd"; 24 | String destName = dataDir + "BinarizationWithOtsuThreshold_out.jpg"; 25 | 26 | Image image = Image.load(sourceFile); 27 | // Cast the image to RasterCachedImage and Check if image is cached 28 | RasterCachedImage rasterCachedImage = (RasterCachedImage)image; 29 | if (!rasterCachedImage.isCached()) 30 | { 31 | // Cache image if not already cached 32 | rasterCachedImage.cacheData(); 33 | } 34 | // Binarize image with Otsu Thresholding and Save the resultant image 35 | rasterCachedImage.binarizeOtsu(); 36 | 37 | rasterCachedImage.save(destName, new JpegOptions()); 38 | //ExEnd:BinarizationWithOtsuThreshold 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/Conversion/BradleyThreshold.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.Conversion; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.examples.Utils.Utils; 10 | import com.aspose.psd.fileformats.psd.PsdImage; 11 | import com.aspose.psd.imageoptions.PngOptions; 12 | 13 | /** 14 | * 15 | * 16 | */ 17 | public class BradleyThreshold 18 | { 19 | public static void main(String[] args) 20 | { 21 | //ExStart:BradleyThreshold 22 | String dataDir = Utils.getDataDir(BradleyThreshold.class) + "Conversion/"; 23 | String sourceFile = dataDir + "sample.psd"; 24 | String destName = dataDir + "binarized_out.png"; 25 | 26 | // Load an image 27 | PsdImage image = (PsdImage)Image.load(sourceFile); 28 | 29 | // Define threshold value, Call BinarizeBradley method and pass the threshold value as parameter and Save the output image 30 | double threshold = 0.15; 31 | image.binarizeBradley(threshold); 32 | image.save(destName, new PngOptions()); 33 | //ExEnd:BradleyThreshold 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/Conversion/CMYKPSDtoCMYKTiff.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.Conversion; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.examples.Utils.Utils; 10 | import com.aspose.psd.fileformats.tiff.enums.TiffExpectedFormat; 11 | import com.aspose.psd.imageoptions.TiffOptions; 12 | 13 | /** 14 | * 15 | * 16 | */ 17 | public class CMYKPSDtoCMYKTiff { 18 | 19 | public static void main(String[] args) 20 | { 21 | //ExStart:CMYKPSDtoCMYKTiff 22 | String dataDir = Utils.getDataDir(CMYKPSDtoCMYKTiff.class) + "Conversion/"; 23 | 24 | String sourceFile = dataDir + "sample.psd"; 25 | String destName = dataDir + "output.tiff"; 26 | 27 | Image image = Image.load(sourceFile); 28 | image.save(destName, new TiffOptions(TiffExpectedFormat.TiffLzwCmyk)); 29 | //ExEnd:CMYKPSDtoCMYKTiff 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/Conversion/CropPSDFile.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.Conversion; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.RasterImage; 10 | import com.aspose.psd.Rectangle; 11 | import com.aspose.psd.examples.Utils.Utils; 12 | import com.aspose.psd.fileformats.png.PngColorType; 13 | import com.aspose.psd.imageoptions.PngOptions; 14 | import com.aspose.psd.imageoptions.PsdOptions; 15 | import com.aspose.psd.xmp.types.complex.colorant.ColorType; 16 | 17 | /** 18 | * 19 | * 20 | */ 21 | public class CropPSDFile { 22 | 23 | public static void main(String[] args) 24 | { 25 | //ExStart:CropPSDFile 26 | String dataDir = Utils.getDataDir(CropPSDFile.class) + "Conversion/"; 27 | 28 | // Implement correct Crop method for PSD files. 29 | String sourceFileName = dataDir + "1.psd"; 30 | String exportPathPsd = dataDir +"CropTest.psd"; 31 | String exportPathPng = dataDir +"CropTest.png"; 32 | 33 | RasterImage image = (RasterImage)Image.load(sourceFileName); 34 | image.crop(new Rectangle(10, 30, 100, 100)); 35 | image.save(exportPathPsd, new PsdOptions()); 36 | 37 | PngOptions options = new PngOptions(); 38 | options.setColorType(PngColorType.TruecolorWithAlpha); 39 | image.save(exportPathPng, options); 40 | //ExEnd:CropPSDFile 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/Conversion/CroppingPSDWhenConvertingToPNG.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.Conversion; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.RasterImage; 10 | import com.aspose.psd.Rectangle; 11 | import com.aspose.psd.examples.Utils.Utils; 12 | import com.aspose.psd.imageoptions.PngOptions; 13 | 14 | /** 15 | * 16 | * 17 | */ 18 | public class CroppingPSDWhenConvertingToPNG { 19 | 20 | public static void main(String[] args) 21 | { 22 | //ExStart:CroppingPSDWhenConvertingToPNG 23 | String dataDir = Utils.getDataDir(ColorConversionUsingICCProfiles.class) + "Conversion/"; 24 | 25 | String srcPath = dataDir + "sample.psd"; 26 | String destName = dataDir + "export.png"; 27 | 28 | // Load an existing PSD image 29 | RasterImage image = (RasterImage)Image.load(srcPath); 30 | // Create an instance of Rectangle class by passing x,y and width,height 31 | // Call the crop method of Image class and pass the rectangle class instance 32 | image.crop(new Rectangle(0, 0, 350, 450)); 33 | 34 | // Create an instance of PngOptions class 35 | PngOptions pngOptions = new PngOptions(); 36 | 37 | // Call the save method, provide output path and PngOptions to convert the PSD file to PNG and save the output 38 | image.save(destName, pngOptions); 39 | 40 | //ExEnd:CroppingPSDWhenConvertingToPNG 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/Conversion/GrayScaling.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.Conversion; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.RasterCachedImage; 10 | import com.aspose.psd.examples.Utils.Utils; 11 | import com.aspose.psd.imageoptions.JpegOptions; 12 | import java.io.FileNotFoundException; 13 | 14 | /** 15 | * 16 | * 17 | */ 18 | public class GrayScaling { 19 | 20 | public static void main(String[] args) 21 | { 22 | //ExStart:GrayScaling 23 | String dataDir = Utils.getDataDir(GrayScaling.class) + "Conversion/"; 24 | 25 | String sourceFile = dataDir + "sample.psd"; 26 | String destName = dataDir +"Grayscaling_out.jpg"; 27 | 28 | Image image = Image.load(sourceFile); 29 | // Cast the image to RasterCachedImage and Check if image is cached 30 | RasterCachedImage rasterCachedImage = (RasterCachedImage)image; 31 | if (!rasterCachedImage.isCached()) 32 | { 33 | // Cache image if not already cached 34 | rasterCachedImage.cacheData(); 35 | } 36 | 37 | // Transform image to its grayscale representation and Save the resultant image 38 | rasterCachedImage.grayscale(); 39 | rasterCachedImage.save(destName, new JpegOptions()); 40 | //ExEnd:GrayScaling 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/Conversion/LoadingFromStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.Conversion; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.examples.Utils.Utils; 10 | import com.aspose.psd.fileformats.psd.PsdImage; 11 | import com.aspose.psd.imageoptions.PngOptions; 12 | import com.aspose.psd.system.io.FileMode; 13 | import com.aspose.psd.system.io.FileStream; 14 | import com.aspose.psd.system.io.MemoryStream; 15 | import java.io.FileInputStream; 16 | import java.io.FileNotFoundException; 17 | import java.io.FileOutputStream; 18 | 19 | /** 20 | * 21 | * 22 | */ 23 | public class LoadingFromStream { 24 | 25 | public static void main(String[] args) throws FileNotFoundException 26 | { 27 | //ExStart:LoadingFromStream 28 | String dataDir = Utils.getDataDir(LoadingFromStream.class) + "Conversion/"; 29 | 30 | String sourceFile = dataDir + "sample.psd"; 31 | String destName = dataDir + "result.png"; 32 | 33 | 34 | FileInputStream inputStream = new FileInputStream(sourceFile); 35 | Image image = Image.load(inputStream); 36 | 37 | PsdImage psdImage = (PsdImage)image; 38 | FileOutputStream outputStream = new FileOutputStream(destName); 39 | psdImage.save(outputStream, new PngOptions()); 40 | 41 | //ExEnd:LoadingFromStream 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/Conversion/RenderTextWithDifferentColorsInTextLayer.java: -------------------------------------------------------------------------------- 1 | package com.aspose.psd.examples.Conversion; 2 | 3 | import com.aspose.psd.Image; 4 | import com.aspose.psd.examples.Utils.Utils; 5 | import com.aspose.psd.fileformats.png.PngColorType; 6 | import com.aspose.psd.fileformats.psd.PsdImage; 7 | import com.aspose.psd.fileformats.psd.layers.TextLayer; 8 | import com.aspose.psd.imageoptions.PngOptions; 9 | 10 | 11 | public class RenderTextWithDifferentColorsInTextLayer { 12 | public static void main(String[] args) { 13 | //ExStart:1 14 | String sourceDir = Utils.GetDataDir_PSD(); 15 | String outputDir = Utils.GetDataDir_Output(); 16 | 17 | String targetFilePath = sourceDir + "text_ethalon_different_colors.psd"; 18 | String resultFilePath = outputDir + "RenderTextWithDifferentColorsInTextLayer_out.png"; 19 | 20 | PsdImage psdImage = null; 21 | try 22 | { 23 | psdImage = (PsdImage) Image.load(targetFilePath); 24 | TextLayer txtLayer = (TextLayer)psdImage.getLayers()[1]; 25 | txtLayer.getTextData().updateLayerData(); 26 | PngOptions pngOptions = new PngOptions(); 27 | pngOptions.setColorType(PngColorType.TruecolorWithAlpha); 28 | psdImage.save(resultFilePath, pngOptions); 29 | } 30 | finally 31 | { 32 | if (psdImage != null) psdImage.dispose(); 33 | } 34 | //ExEnd:1 35 | 36 | System.out.println("RenderTextWithDifferentColorsInTextLayer executed successfully"); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/Conversion/SavingToDisk.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.Conversion; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.examples.Utils.Utils; 10 | import com.aspose.psd.fileformats.psd.PsdImage; 11 | import com.aspose.psd.imageoptions.PngOptions; 12 | 13 | /** 14 | * 15 | * 16 | */ 17 | public class SavingToDisk 18 | { 19 | public static void main(String[] args) 20 | { 21 | //ExStart:SavingToDisk 22 | String dataDir = Utils.getDataDir(SavingToDisk.class) + "Conversion/"; 23 | String sourceFile = dataDir + "sample.psd"; 24 | String destName = dataDir + "result.png"; 25 | 26 | // load PSD image and replace the non found fonts. 27 | Image image = Image.load(sourceFile); 28 | 29 | PsdImage psdImage = (PsdImage)image; 30 | psdImage.save(destName, new PngOptions()); 31 | 32 | //ExEnd:SavingToDisk 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/Conversion/SavingToStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.Conversion; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.examples.Utils.Utils; 10 | import com.aspose.psd.fileformats.psd.PsdImage; 11 | import com.aspose.psd.imageoptions.PngOptions; 12 | 13 | import java.io.FileNotFoundException; 14 | import java.io.FileOutputStream; 15 | 16 | /** 17 | * 18 | * 19 | */ 20 | public class SavingToStream 21 | { 22 | public static void main(String[] args) throws FileNotFoundException 23 | { 24 | //ExStart:SavingToStream 25 | String dataDir = Utils.getDataDir(SavingToStream.class) + "Conversion/"; 26 | 27 | 28 | 29 | String sourceFile = dataDir + "sample.psd"; 30 | String destName = dataDir + "result.png"; 31 | 32 | // load PSD image and replace the non found fonts. 33 | Image image = Image.load(sourceFile); 34 | 35 | PsdImage psdImage = (PsdImage)image; 36 | FileOutputStream outputStream = new FileOutputStream(destName); 37 | psdImage.save(outputStream, new PngOptions()); 38 | 39 | //ExEnd:SavingToStream 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/Conversion/SettingForReplacingMissingFonts.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.Conversion; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.examples.Utils.Utils; 10 | import com.aspose.psd.fileformats.png.PngColorType; 11 | import com.aspose.psd.fileformats.psd.PsdImage; 12 | import com.aspose.psd.imageloadoptions.PsdLoadOptions; 13 | import com.aspose.psd.imageoptions.PngOptions; 14 | 15 | /** 16 | * 17 | * 18 | */ 19 | public class SettingForReplacingMissingFonts 20 | { 21 | public static void main(String[] args) 22 | { 23 | //ExStart:SettingForReplacingMissingFonts 24 | String dataDir = Utils.getDataDir(SettingForReplacingMissingFonts.class) + "Conversion/"; 25 | 26 | String sourceFile = dataDir + "sample.psd"; 27 | String destName = dataDir + "result.png"; 28 | 29 | PsdLoadOptions loadOptions = new PsdLoadOptions(); 30 | loadOptions.setDefaultReplacementFont("Arial"); 31 | 32 | // load PSD image and replace the non found fonts. 33 | Image image = Image.load(sourceFile,loadOptions); 34 | 35 | PsdImage psdImage = (PsdImage)image; 36 | 37 | PngOptions Options = new PngOptions(); 38 | Options.setColorType(PngColorType.TruecolorWithAlpha); 39 | psdImage.save(destName, Options); 40 | 41 | 42 | //ExEnd:SettingForReplacingMissingFonts 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/Conversion/SyncRoot.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.Conversion; 7 | 8 | import com.aspose.psd.StreamContainer; 9 | import com.aspose.psd.examples.Utils.Utils; 10 | import com.aspose.psd.system.io.MemoryStream; 11 | 12 | 13 | 14 | public class SyncRoot { 15 | 16 | public static void main(String[] args) 17 | { 18 | //ExStart:SyncRoot 19 | String dataDir = Utils.getDataDir(SyncRoot.class) + "Conversion/"; 20 | 21 | 22 | // Create an instance of Stream container class and assign memory stream object. 23 | StreamContainer streamContainer = new StreamContainer(new java.io.ByteArrayInputStream(new byte[0])); 24 | 25 | try 26 | { 27 | // check if the access to the stream source is synchronized. 28 | synchronized (streamContainer.getSyncRoot()) 29 | { 30 | // do work 31 | // now access to streamContainer is synchronized 32 | } 33 | } 34 | finally 35 | { 36 | streamContainer.dispose(); 37 | } 38 | //ExEnd:SyncRoot 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/DrawingAndFormattingImages/BlurAnImage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.DrawingAndFormattingImages; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.RasterImage; 10 | import com.aspose.psd.examples.Utils.Utils; 11 | import com.aspose.psd.imagefilters.filteroptions.GaussianBlurFilterOptions; 12 | import com.aspose.psd.imageoptions.GifOptions; 13 | 14 | /** 15 | * 16 | * 17 | */ 18 | public class BlurAnImage { 19 | public static void main(String[] args) 20 | { 21 | //ExStart:BlurAnImage 22 | String dataDir = Utils.getDataDir(BlurAnImage.class) + "DrawingAndFormattingImages/"; 23 | 24 | String sourceFile = dataDir + "sample.psd"; 25 | String destName = dataDir + "BlurAnImage_out.gif"; 26 | 27 | // Load an existing image into an instance of RasterImage class 28 | Image image = Image.load(sourceFile); 29 | // Convert the image into RasterImage, 30 | //Pass Bounds[rectangle] of image and GaussianBlurFilterOptions instance to Filter method and Save the results 31 | RasterImage rasterImage = (RasterImage)image; 32 | 33 | rasterImage.filter(rasterImage.getBounds(), new GaussianBlurFilterOptions(15, 15)); 34 | 35 | rasterImage.save(destName, new GifOptions()); 36 | //ExEnd:BlurAnImage 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/DrawingAndFormattingImages/ColorOverlayEffect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.DrawingAndFormattingImages; 7 | 8 | import com.aspose.psd.Color; 9 | import com.aspose.psd.Image; 10 | import com.aspose.psd.examples.Utils.Utils; 11 | import com.aspose.psd.fileformats.psd.PsdImage; 12 | import com.aspose.psd.imageloadoptions.PsdLoadOptions; 13 | 14 | /** 15 | * 16 | * 17 | */ 18 | public class ColorOverlayEffect 19 | { 20 | public static void main(String[] args) 21 | { 22 | //ExStart:ColorOverlayEffect 23 | String dataDir = Utils.getDataDir(ColorOverlayEffect.class) + "DrawingAndFormattingImages/"; 24 | // ColorOverlay effect editing 25 | String sourceFileName = dataDir+"ColorOverlay.psd"; 26 | String psdPathAfterChange =dataDir+ "ColorOverlayChanged.psd"; 27 | 28 | PsdLoadOptions loadOptions = new PsdLoadOptions(); 29 | loadOptions.setLoadEffectsResource(true); 30 | 31 | PsdImage im = (PsdImage)Image.load(sourceFileName, loadOptions); 32 | 33 | com.aspose.psd.fileformats.psd.layers.layereffects.ColorOverlayEffect colorOverlay = (com.aspose.psd.fileformats.psd.layers.layereffects.ColorOverlayEffect)(im.getLayers()[1].getBlendingOptions().getEffects()[0]); 34 | 35 | colorOverlay.setColor(Color.getGreen()) ; 36 | colorOverlay.setOpacity((byte)128); 37 | 38 | im.save(psdPathAfterChange); 39 | //ExEnd:ColorOverlayEffect 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/DrawingAndFormattingImages/CreatingBySettingPath.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.DrawingAndFormattingImages; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.examples.Utils.Utils; 10 | import com.aspose.psd.fileformats.psd.CompressionMethod; 11 | import com.aspose.psd.imageoptions.PsdOptions; 12 | import com.aspose.psd.sources.FileCreateSource; 13 | 14 | /** 15 | * 16 | * 17 | */ 18 | public class CreatingBySettingPath 19 | { 20 | public static void main(String[] args) 21 | { 22 | //ExStart:CreatingBySettingPath 23 | String dataDir = Utils.getDataDir(CreatingBySettingPath.class) + "DrawingAndFormattingImages/"; 24 | String desName = dataDir + "CreatingAnImageBySettingPath_out.psd"; 25 | // Creates an instance of PsdOptions and set its various properties 26 | PsdOptions psdOptions = new PsdOptions(); 27 | psdOptions.setCompressionMethod(CompressionMethod.RLE); 28 | 29 | // Define the source property for the instance of PsdOptions. Second boolean parameter determines if the file is temporal or not 30 | psdOptions.setSource(new FileCreateSource(desName, false)); 31 | // Creates an instance of Image and call Create method by passing the PsdOptions object 32 | Image image = Image.create(psdOptions, 500, 500); 33 | image.save(); 34 | //ExEnd:CreatingBySettingPath 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/DrawingAndFormattingImages/CroppingByRectangle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.DrawingAndFormattingImages; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.RasterImage; 10 | import com.aspose.psd.Rectangle; 11 | import com.aspose.psd.examples.Utils.Utils; 12 | import com.aspose.psd.imageoptions.JpegOptions; 13 | 14 | /** 15 | * 16 | * 17 | */ 18 | public class CroppingByRectangle 19 | { 20 | public static void main(String[] args) 21 | { 22 | //ExStart:CroppingByRectangle 23 | String dataDir = Utils.getDataDir(CroppingByRectangle.class) + "DrawingAndFormattingImages/"; 24 | 25 | String sourceFile = dataDir + "sample.psd"; 26 | String destName = dataDir + "CroppingByRectangle_out.jpg"; 27 | 28 | // Load an existing image into an instance of RasterImage class 29 | RasterImage rasterImage = (RasterImage)Image.load(sourceFile); 30 | 31 | if (!rasterImage.isCached()) 32 | { 33 | rasterImage.cacheData(); 34 | } 35 | 36 | // Create an instance of Rectangle class with desired size, 37 | //Perform the crop operation on object of Rectangle class and Save the results to disk 38 | Rectangle rectangle = new Rectangle(20, 20, 20, 20); 39 | 40 | rasterImage.crop(rectangle); 41 | rasterImage.save(destName, new JpegOptions()); 42 | 43 | //ExEnd:CroppingByRectangle 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/DrawingAndFormattingImages/DitheringForRasterImages.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.DrawingAndFormattingImages; 7 | 8 | import com.aspose.psd.DitheringMethod; 9 | import com.aspose.psd.Image; 10 | import com.aspose.psd.examples.Utils.Utils; 11 | import com.aspose.psd.fileformats.psd.PsdImage; 12 | import com.aspose.psd.imageoptions.BmpOptions; 13 | 14 | 15 | public class DitheringForRasterImages 16 | { 17 | public static void main(String[] args) 18 | { 19 | //ExStart:DitheringForRasterImages 20 | String dataDir = Utils.getDataDir(DitheringForRasterImages.class) + "DrawingAndFormattingImages/"; 21 | String sourceFile = dataDir + "sample.psd"; 22 | String destName = dataDir + "SampleImage_out.bmp"; 23 | 24 | // Load an existing image into an instance of RasterImage class 25 | PsdImage image = (PsdImage)Image.load(sourceFile); 26 | 27 | // Peform Floyd Steinberg dithering on the current image and Save the resultant image 28 | image.dither(DitheringMethod.ThresholdDithering, 4); 29 | image.save(destName, new BmpOptions()); 30 | 31 | 32 | //ExEnd:DitheringForRasterImages 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/DrawingAndFormattingImages/ExpandAndCropImages.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.DrawingAndFormattingImages; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.RasterImage; 10 | import com.aspose.psd.Rectangle; 11 | import com.aspose.psd.examples.Utils.Utils; 12 | import com.aspose.psd.imageoptions.JpegOptions; 13 | 14 | /** 15 | * 16 | * 17 | */ 18 | public class ExpandAndCropImages { 19 | 20 | public static void main(String[] args) 21 | { 22 | //ExStart:ExpandAndCropImages 23 | String dataDir = Utils.getDataDir(ExpandAndCropImages.class) + "DrawingAndFormattingImages/"; 24 | 25 | String sourceFile = dataDir + "example1.psd"; 26 | String destName = dataDir + "jpeg_out.jpg"; 27 | 28 | RasterImage rasterImage = (RasterImage)Image.load(sourceFile); 29 | rasterImage.cacheData(); 30 | // Create an instance of Rectangle class and define X,Y and Width, height of the rectangle, and Save output image 31 | Rectangle destRect = new Rectangle(-200, -200, 300, 300); 32 | rasterImage.save(destName, new JpegOptions(), destRect); 33 | //ExEnd:ExpandAndCropImages 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/DrawingAndFormattingImages/FontReplacement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.DrawingAndFormattingImages; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.examples.Utils.Utils; 10 | import com.aspose.psd.fileformats.psd.PsdImage; 11 | import com.aspose.psd.imageloadoptions.PsdLoadOptions; 12 | import com.aspose.psd.imageoptions.PngOptions; 13 | 14 | /** 15 | * 16 | * 17 | */ 18 | public class FontReplacement { 19 | public static void main(String[] args) 20 | { 21 | //ExStart:FontReplacement 22 | String dataDir = Utils.getDataDir(FontReplacement.class) + "DrawingAndFormattingImages/"; 23 | 24 | // Load an image in an instance of image and setting default replacement font. 25 | PsdLoadOptions psdLoadOptions = new PsdLoadOptions(); 26 | psdLoadOptions.setDefaultReplacementFont("Arial"); 27 | 28 | PsdImage psdImage = (PsdImage)Image.load(dataDir +"Cloud_AzPlat_Banner3A_SB_EN_US_160x600_chinese_font.psd", psdLoadOptions); 29 | 30 | PngOptions pngOptions = new PngOptions(); 31 | psdImage.save(dataDir + "replaced_font.png", pngOptions); 32 | 33 | 34 | //ExEnd:FontReplacement 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/DrawingAndFormattingImages/ForceFontCache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.DrawingAndFormattingImages; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.OpenTypeFontsCache; 10 | import com.aspose.psd.examples.Utils.Utils; 11 | import com.aspose.psd.fileformats.psd.PsdImage; 12 | import java.io.Console; 13 | import java.util.concurrent.TimeUnit; 14 | 15 | /** 16 | * 17 | * 18 | */ 19 | public class ForceFontCache { 20 | public static void main(String[] args) throws InterruptedException 21 | { 22 | //ExStart:ForceFontCache 23 | String dataDir = Utils.getDataDir(ForceFontCache.class) + "DrawingAndFormattingImages/"; 24 | 25 | PsdImage image = (PsdImage)Image.load(dataDir+"sample.psd"); 26 | image.save(dataDir+"NoFont.psd"); 27 | 28 | 29 | System.out.println("You have 2 minutes to install the font"); 30 | Thread.sleep(2 * 60 * 1000); 31 | OpenTypeFontsCache.updateCache(); 32 | 33 | PsdImage image1 = (PsdImage)Image.load(dataDir+ "sample.psd"); 34 | image1.save(dataDir+"HasFont.psd"); 35 | 36 | //ExEnd:ForceFontCache 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/DrawingAndFormattingImages/ImplementBicubicResampler.java: -------------------------------------------------------------------------------- 1 | 2 | package com.aspose.psd.examples.DrawingAndFormattingImages; 3 | 4 | import com.aspose.psd.Image; 5 | import com.aspose.psd.ResizeType; 6 | import com.aspose.psd.examples.Utils.Utils; 7 | import com.aspose.psd.fileformats.psd.PsdImage; 8 | import com.aspose.psd.imageoptions.PsdOptions; 9 | 10 | 11 | public class ImplementBicubicResampler { 12 | 13 | public static void main(String[] args) 14 | { 15 | //ExStart:ImplementBicubicResampler 16 | String dataDir = Utils.getDataDir(ImplementBicubicResampler.class) + "DrawingAndFormattingImages/"; 17 | 18 | String filePath = dataDir + "sample_bicubic.psd"; 19 | String destNameCubicConvolution = dataDir + "ResamplerCubicConvolutionStripes_after.psd"; 20 | 21 | PsdImage image = (PsdImage)Image.load(filePath); 22 | image.resize(300, 300, ResizeType.CubicConvolution); 23 | image.save(destNameCubicConvolution, new PsdOptions(image)); 24 | 25 | 26 | String destNameBell = dataDir +"ResamplerBellStripes_after.psd"; 27 | PsdImage imageBellStripes = (PsdImage)Image.load(filePath); 28 | imageBellStripes.resize(300, 300, ResizeType.Bell); 29 | imageBellStripes.save(destNameCubicConvolution, new PsdOptions(imageBellStripes)); 30 | 31 | 32 | //ExEnd:ImplementBicubicResampler 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/DrawingAndFormattingImages/ImplementLossyGIFCompressor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.DrawingAndFormattingImages; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.examples.Utils.Utils; 10 | import com.aspose.psd.imageoptions.GifOptions; 11 | 12 | /** 13 | * 14 | * 15 | */ 16 | public class ImplementLossyGIFCompressor { 17 | 18 | public static void main(String[] args) throws InterruptedException 19 | { 20 | //ExStart:ImplementLossyGIFCompressor 21 | String dataDir = Utils.getDataDir(ImplementLossyGIFCompressor.class) + "DrawingAndFormattingImages/"; 22 | 23 | String sourceFile = dataDir + "sample.psd"; 24 | String destName = dataDir + "anim_lossy-200.gif"; 25 | 26 | 27 | // Load an existing image into an instance of RasterImage class 28 | Image image = Image.load(sourceFile); 29 | 30 | GifOptions gifExport = new GifOptions(); 31 | gifExport.setMaxDiff(80); 32 | image.save(dataDir + "anim_lossy-80.gif", gifExport); 33 | 34 | 35 | gifExport.setMaxDiff(200); 36 | image.save(destName, gifExport); 37 | //ExEnd:ImplementLossyGIFCompressor 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/DrawingAndFormattingImages/InvertAdjustmentLayer.java: -------------------------------------------------------------------------------- 1 | 2 | package com.aspose.psd.examples.DrawingAndFormattingImages; 3 | 4 | import com.aspose.psd.Image; 5 | import com.aspose.psd.examples.Utils.Utils; 6 | import com.aspose.psd.fileformats.psd.PsdImage; 7 | 8 | 9 | public class InvertAdjustmentLayer { 10 | 11 | public static void main(String[] args) 12 | { 13 | //ExStart:InvertAdjustmentLayer 14 | String dataDir = Utils.getDataDir(InvertAdjustmentLayer.class) + "DrawingAndFormattingImages/"; 15 | 16 | String filePath = dataDir + "InvertStripes_before.psd"; 17 | String outputPath = dataDir + "InvertStripes_after.psd"; 18 | 19 | PsdImage im = (PsdImage)Image.load(filePath); 20 | 21 | im.addInvertAdjustmentLayer(); 22 | im.save(outputPath); 23 | //ExEnd:InvertAdjustmentLayer 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/DrawingAndFormattingImages/RenderingColorEffect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.DrawingAndFormattingImages; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.examples.Utils.Utils; 10 | import com.aspose.psd.fileformats.png.PngColorType; 11 | import com.aspose.psd.fileformats.psd.PsdImage; 12 | import com.aspose.psd.fileformats.psd.layers.layereffects.ColorOverlayEffect; 13 | import com.aspose.psd.imageloadoptions.PsdLoadOptions; 14 | import com.aspose.psd.imageoptions.PngOptions; 15 | 16 | /** 17 | * 18 | * 19 | */ 20 | public class RenderingColorEffect { 21 | 22 | public static void main(String[] args) throws InterruptedException 23 | { 24 | //ExStart:RenderingColorEffect 25 | String dataDir = Utils.getDataDir(RenderingColorEffect.class) + "DrawingAndFormattingImages/"; 26 | 27 | 28 | String sourceFileName = dataDir+"ColorOverlay.psd"; 29 | String pngExportPath = dataDir+"ColorOverlayresult.png"; 30 | 31 | PsdLoadOptions loadOptions = new PsdLoadOptions(); 32 | loadOptions.setLoadEffectsResource(true); 33 | 34 | PsdImage im = (PsdImage)Image.load(sourceFileName, loadOptions); 35 | ColorOverlayEffect colorOverlay = (ColorOverlayEffect)(im.getLayers()[1].getBlendingOptions().getEffects()[0]); 36 | 37 | PngOptions saveOptions = new PngOptions(); 38 | saveOptions.setColorType(PngColorType.TruecolorWithAlpha) ; 39 | im.save(pngExportPath, saveOptions); 40 | //ExEnd:RenderingColorEffect 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/DrawingAndFormattingImages/ResizeImageProportionally.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.DrawingAndFormattingImages; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.examples.Utils.Utils; 10 | import com.aspose.psd.imageoptions.PngOptions; 11 | 12 | /** 13 | * 14 | * 15 | */ 16 | public class ResizeImageProportionally { 17 | 18 | public static void main(String[] args) 19 | { 20 | //ExStart:ResizeImageProportionally 21 | String dataDir = Utils.getDataDir(ResizeImageProportionally.class) + "DrawingAndFormattingImages/"; 22 | 23 | String sourceFile = dataDir + "sample.psd"; 24 | String destName = dataDir + "SimpleResizeImageProportionally_out.png"; 25 | 26 | Image image = Image.load(sourceFile); 27 | 28 | if (!image.isCached()) 29 | { 30 | image.cacheData(); 31 | } 32 | // Specifying width and height 33 | int newWidth = image.getWidth() / 2; 34 | image.resizeWidthProportionally(newWidth); 35 | int newHeight = image.getHeight() / 2; 36 | image.resizeHeightProportionally(newHeight); 37 | image.save(destName, new PngOptions()); 38 | //ExEnd:ResizeImageProportionally 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/DrawingAndFormattingImages/ResizingWithResizeTypeEnumeration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.DrawingAndFormattingImages; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.ResizeType; 10 | import com.aspose.psd.examples.Utils.Utils; 11 | import com.aspose.psd.imageoptions.JpegOptions; 12 | 13 | /** 14 | * 15 | * 16 | */ 17 | public class ResizingWithResizeTypeEnumeration 18 | { 19 | public static void main(String[] args) 20 | { 21 | //ExStart:ResizingWithResizeTypeEnumeration 22 | String dataDir = Utils.getDataDir(ResizingWithResizeTypeEnumeration.class) + "DrawingAndFormattingImages/"; 23 | 24 | String sourceFile = dataDir + "sample.psd"; 25 | String destName = dataDir + "ResizingwithResizeTypeEnumeration_out.jpg"; 26 | 27 | // Load an existing image into an instance of RasterImage class 28 | Image image = Image.load(sourceFile); 29 | image.resize(300, 300, ResizeType.LanczosResample); 30 | image.save(destName, new JpegOptions()); 31 | //ExEnd:ResizingWithResizeTypeEnumeration 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/DrawingAndFormattingImages/RotatingAnImage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.DrawingAndFormattingImages; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.RotateFlipType; 10 | import com.aspose.psd.examples.Utils.Utils; 11 | import com.aspose.psd.imageoptions.JpegOptions; 12 | 13 | /** 14 | * 15 | * 16 | */ 17 | public class RotatingAnImage 18 | { 19 | public static void main(String[] args) 20 | { 21 | //ExStart:RotatingAnImage 22 | String dataDir = Utils.getDataDir(RotatingAnImage.class) + "DrawingAndFormattingImages/"; 23 | 24 | String sourceFile = dataDir + "sample.psd"; 25 | String destName = dataDir + "RotatingAnImage_out.jpg"; 26 | 27 | // Load an existing image into an instance of RasterImage class 28 | Image image = Image.load(sourceFile); 29 | image.rotateFlip(RotateFlipType.Rotate270FlipNone); 30 | image.save(destName, new JpegOptions()); 31 | //ExEnd:RotatingAnImage 32 | } 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/DrawingAndFormattingImages/RotatingAnImageOnASpecificAngle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.DrawingAndFormattingImages; 7 | 8 | import com.aspose.psd.Color; 9 | import com.aspose.psd.Image; 10 | import com.aspose.psd.RasterImage; 11 | import com.aspose.psd.examples.Utils.Utils; 12 | import com.aspose.psd.imageoptions.JpegOptions; 13 | 14 | /** 15 | * 16 | * 17 | */ 18 | public class RotatingAnImageOnASpecificAngle 19 | { 20 | public static void main(String[] args) 21 | { 22 | //ExStart:RotatingAnImageOnASpecificAngle 23 | String dataDir = Utils.getDataDir(RotatingAnImageOnASpecificAngle.class) + "DrawingAndFormattingImages/"; 24 | 25 | String sourceFile = dataDir + "sample.psd"; 26 | String destName = dataDir + "RotatingImageOnSpecificAngle_out.jpg"; 27 | 28 | RasterImage image = (RasterImage)Image.load(sourceFile); 29 | // Before rotation, the image should be cached for better performance 30 | if (!image.isCached()) 31 | { 32 | image.cacheData(); 33 | } 34 | // Perform the rotation on 20 degree while keeping the image size proportional with red background color and Save the result to a new file 35 | image.rotate(20f, true, Color.getRed()); 36 | image.save(destName, new JpegOptions()); 37 | //ExEnd:RotatingAnImageOnASpecificAngle 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/DrawingAndFormattingImages/SimpleResizing.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.DrawingAndFormattingImages; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.examples.Utils.Utils; 10 | import com.aspose.psd.imageoptions.JpegOptions; 11 | 12 | /** 13 | * 14 | * 15 | */ 16 | public class SimpleResizing { 17 | 18 | public static void main(String[] args) 19 | { 20 | //ExStart:SimpleResizing 21 | String dataDir = Utils.getDataDir(SimpleResizing.class) + "DrawingAndFormattingImages/"; 22 | 23 | String sourceFile = dataDir + "sample.psd"; 24 | String destName = dataDir + "SimpleResizing_out.jpg"; 25 | 26 | // Load an existing image into an instance of RasterImage class 27 | Image image = Image.load(sourceFile); 28 | 29 | image.resize(300, 300); 30 | image.save(destName, new JpegOptions()); 31 | //ExEnd:SimpleResizing 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/DrawingAndFormattingImages/VerifyImageTransparency.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.DrawingAndFormattingImages; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.examples.Utils.Utils; 10 | import com.aspose.psd.fileformats.psd.PsdImage; 11 | 12 | /** 13 | * 14 | * 15 | */ 16 | public class VerifyImageTransparency { 17 | 18 | public static void main(String[] args) 19 | { 20 | //ExStart:VerifyImageTransparency 21 | String dataDir = Utils.getDataDir(VerifyImageTransparency.class) + "DrawingAndFormattingImages/"; 22 | 23 | String sourceFile = dataDir +"sample.psd"; 24 | String destName = dataDir + "AdjustBrightness_out.tiff"; 25 | 26 | // Load an existing image into an instance of RasterImage class 27 | PsdImage image = (PsdImage)Image.load(sourceFile); 28 | 29 | float opacity = image.getImageOpacity(); 30 | System.out.println(opacity); 31 | if (opacity == 0) 32 | { 33 | // The image is fully transparent. 34 | } 35 | //ExEnd:VerifyImageTransparency 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/Licensing/MeteredLicensing.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.Licensing; 7 | 8 | import com.aspose.psd.Metered; 9 | import java.math.BigDecimal; 10 | 11 | 12 | public class MeteredLicensing { 13 | 14 | public static void main(String[] args) 15 | { 16 | //ExStart:MeteredLicensing 17 | 18 | // Create an instance of PSD Metered class 19 | Metered metered = new Metered(); 20 | 21 | // Access the setMeteredKey property and pass public and private keys as parameters 22 | metered.setMeteredKey("*****", "*****"); 23 | 24 | // Get metered data amount before calling API 25 | 26 | System.out.println("Amount Consumed Before: " + Metered.getConsumptionQuantity()); 27 | 28 | // Get metered data amount After calling API 29 | 30 | System.out.println("Amount Consumed After: " + Metered.getConsumptionQuantity()); 31 | 32 | //ExEnd:MeteredLicensing 33 | 34 | //ExEnd:MeteredLicensing 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/AI/AIToGIF.java: -------------------------------------------------------------------------------- 1 | 2 | package com.aspose.psd.examples.ModifyingAndConvertingImages.AI; 3 | 4 | import com.aspose.psd.Image; 5 | import com.aspose.psd.ImageOptionsBase; 6 | import com.aspose.psd.examples.Utils.Utils; 7 | import com.aspose.psd.fileformats.ai.AiImage; 8 | import com.aspose.psd.imageoptions.GifOptions; 9 | 10 | 11 | public class AIToGIF { 12 | 13 | public static void main(String[] args) 14 | { 15 | //ExStart:AIToGIF 16 | String dataDir = Utils.getDataDir(AIToGIF.class) + "AI/"; 17 | 18 | String sourceFileName = dataDir + "34992OStroke.ai"; 19 | String outFileName = dataDir + "34992OStroke.gif"; 20 | 21 | AiImage image = (AiImage)Image.load(sourceFileName); 22 | 23 | GifOptions options = new GifOptions(); 24 | options.setDoPaletteCorrection(false); 25 | image.save(outFileName, options); 26 | //ExEnd:AIToGIF 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/AI/AIToJPG.java: -------------------------------------------------------------------------------- 1 | 2 | package com.aspose.psd.examples.ModifyingAndConvertingImages.AI; 3 | 4 | import com.aspose.psd.Image; 5 | import com.aspose.psd.ImageOptionsBase; 6 | import com.aspose.psd.examples.Utils.Utils; 7 | import com.aspose.psd.fileformats.ai.AiImage; 8 | import com.aspose.psd.imageoptions.JpegOptions; 9 | 10 | 11 | public class AIToJPG { 12 | 13 | public static void main(String[] args) 14 | { 15 | //ExStart:AIToJPG 16 | String dataDir = Utils.getDataDir(AIToJPG.class) + "AI/"; 17 | 18 | String sourceFileName = dataDir + "34992OStroke.ai"; 19 | String outFileName = dataDir + "34992OStroke.jpg"; 20 | 21 | AiImage image = (AiImage)Image.load(sourceFileName); 22 | 23 | JpegOptions options = new JpegOptions(); 24 | options.setQuality(85); 25 | 26 | image.save(outFileName, options); 27 | //ExEnd:AIToJPG 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/AI/AIToPDF.java: -------------------------------------------------------------------------------- 1 | 2 | package com.aspose.psd.examples.ModifyingAndConvertingImages.AI; 3 | 4 | import com.aspose.psd.Image; 5 | import com.aspose.psd.examples.Utils.Utils; 6 | import com.aspose.psd.fileformats.ai.AiImage; 7 | import com.aspose.psd.imageoptions.PdfOptions; 8 | 9 | 10 | public class AIToPDF { 11 | 12 | public static void main(String[] args) 13 | { 14 | //ExStart:AIToPDF 15 | String dataDir = Utils.getDataDir(AIToPDF.class) + "AI/"; 16 | 17 | String sourceFileName = dataDir + "34992OStroke.ai"; 18 | String outFileName = dataDir + "34992OStroke.pdf"; 19 | 20 | AiImage image = (AiImage)Image.load(sourceFileName); 21 | 22 | PdfOptions options = new PdfOptions(); 23 | 24 | image.save(outFileName, options); 25 | //ExEnd:AIToPDF 26 | } 27 | } -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/AI/AIToPNG.java: -------------------------------------------------------------------------------- 1 | 2 | package com.aspose.psd.examples.ModifyingAndConvertingImages.AI; 3 | 4 | import com.aspose.psd.Image; 5 | import com.aspose.psd.examples.Utils.Utils; 6 | import com.aspose.psd.fileformats.ai.AiImage; 7 | import com.aspose.psd.fileformats.png.PngColorType; 8 | import com.aspose.psd.imageoptions.PngOptions; 9 | 10 | 11 | public class AIToPNG { 12 | 13 | public static void main(String[] args) 14 | { 15 | //ExStart:AIToPNG 16 | String dataDir = Utils.getDataDir(AIToPNG.class) + "AI/"; 17 | 18 | String sourceFileName = dataDir + "34992OStroke.ai"; 19 | String outFileName = dataDir + "34992OStroke.png"; 20 | 21 | AiImage image = (AiImage)Image.load(sourceFileName); 22 | 23 | PngOptions options = new PngOptions(); 24 | options.setColorType(PngColorType.TruecolorWithAlpha); 25 | 26 | image.save(outFileName, options); 27 | //ExEnd:AIToPNG 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/AI/AIToPSD.java: -------------------------------------------------------------------------------- 1 | 2 | package com.aspose.psd.examples.ModifyingAndConvertingImages.AI; 3 | 4 | import com.aspose.psd.Image; 5 | import com.aspose.psd.examples.Utils.Utils; 6 | import com.aspose.psd.fileformats.ai.AiImage; 7 | import com.aspose.psd.imageoptions.PsdOptions; 8 | 9 | 10 | public class AIToPSD { 11 | 12 | public static void main(String[] args) 13 | { 14 | //ExStart:AIToPSD 15 | String dataDir = Utils.getDataDir(AIToPSD.class) + "AI/"; 16 | 17 | String sourceFileName = dataDir + "34992OStroke.ai"; 18 | String outFileName = dataDir + "34992OStroke.psd"; 19 | 20 | AiImage image = (AiImage)Image.load(sourceFileName); 21 | 22 | PsdOptions options = new PsdOptions(); 23 | 24 | image.save(outFileName, options); 25 | //ExEnd:AIToPSD 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/AI/AIToTIFF.java: -------------------------------------------------------------------------------- 1 | 2 | package com.aspose.psd.examples.ModifyingAndConvertingImages.AI; 3 | 4 | import com.aspose.psd.Image; 5 | import com.aspose.psd.examples.Utils.Utils; 6 | import com.aspose.psd.fileformats.ai.AiImage; 7 | import com.aspose.psd.fileformats.tiff.enums.TiffExpectedFormat; 8 | import com.aspose.psd.imageoptions.TiffOptions; 9 | 10 | 11 | public class AIToTIFF { 12 | 13 | public static void main(String[] args) 14 | { 15 | //ExStart:AIToTIFF 16 | String dataDir = Utils.getDataDir(AIToTIFF.class) + "AI/"; 17 | 18 | String sourceFileName = dataDir + "34992OStroke.ai"; 19 | String outFileName = dataDir + "34992OStroke.tiff"; 20 | 21 | AiImage image = (AiImage)Image.load(sourceFileName); 22 | 23 | 24 | image.save(outFileName, new TiffOptions(TiffExpectedFormat.TiffDeflateRgba)); 25 | //ExEnd:AIToTIFF 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/JPEG/ColorTypeAndCompressionType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.ModifyingAndConvertingImages.JPEG; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.examples.Utils.Utils; 10 | import com.aspose.psd.fileformats.jpeg.JpegCompressionColorMode; 11 | import com.aspose.psd.fileformats.jpeg.JpegCompressionMode; 12 | import com.aspose.psd.fileformats.psd.PsdImage; 13 | import com.aspose.psd.imageoptions.JpegOptions; 14 | 15 | /** 16 | * 17 | * 18 | */ 19 | public class ColorTypeAndCompressionType { 20 | 21 | public static void main(String[] args) 22 | { 23 | //ExStart:ColorTypeAndCompressionType 24 | String dataDir = Utils.getDataDir(ColorTypeAndCompressionType.class) + "ModifyingAndConvertingImages/"; 25 | 26 | PsdImage image = (PsdImage)Image.load(dataDir + "PsdImage.psd"); 27 | 28 | 29 | JpegOptions options = new JpegOptions(); 30 | options.setColorType(JpegCompressionColorMode.Grayscale); 31 | options.setCompressionType(JpegCompressionMode.Progressive) ; 32 | 33 | image.save(dataDir + "ColorTypeAndCompressionType_output.jpg", options); 34 | //ExEnd:ColorTypeAndCompressionType 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PNG/ApplyFilterMethod.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.ModifyingAndConvertingImages.PNG; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.examples.Utils.Utils; 10 | import com.aspose.psd.fileformats.png.PngFilterType; 11 | import com.aspose.psd.fileformats.psd.PsdImage; 12 | import com.aspose.psd.imageoptions.PngOptions; 13 | 14 | /** 15 | * 16 | * 17 | */ 18 | public class ApplyFilterMethod { 19 | public static void main(String[] args) 20 | { 21 | //ExStart:ApplyFilterMethod 22 | String dataDir = Utils.getDataDir(ApplyFilterMethod.class) + "ModifyingAndConvertingImages/"; 23 | 24 | PsdImage psdImage = (PsdImage)Image.load(dataDir + "sample.psd"); 25 | 26 | // Create an instance of PngOptions, Set the PNG filter method and Save changes to the disc 27 | PngOptions options = new PngOptions(); 28 | options.setFilterType(PngFilterType.Paeth); 29 | psdImage.save(dataDir+"ApplyFilterMethod_out.png", options); 30 | //ExEnd:ApplyFilterMethod 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PNG/CompressingFiles.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.ModifyingAndConvertingImages.PNG; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.examples.Utils.Utils; 10 | import com.aspose.psd.fileformats.psd.PsdImage; 11 | import com.aspose.psd.imageoptions.PngOptions; 12 | 13 | /** 14 | * 15 | * 16 | */ 17 | public class CompressingFiles { 18 | public static void main(String[] args) 19 | { 20 | //ExStart:CompressingFiles 21 | String dataDir = Utils.getDataDir(ApplyFilterMethod.class) + "ModifyingAndConvertingImages/"; 22 | 23 | PsdImage psdImage = (PsdImage)Image.load(dataDir + "sample.psd"); 24 | // Loop over possible CompressionLevel range 25 | for (int i = 0; i <= 9; i++) 26 | { 27 | // Create an instance of PngOptions for each resultant PNG, Set CompressionLevel and Save result on disk 28 | PngOptions options = new PngOptions(); 29 | options.setCompressionLevel(i); 30 | psdImage.save(dataDir+i + "_out.png", options); 31 | } 32 | //ExEnd:CompressingFiles 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PNG/SettingResolution.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.ModifyingAndConvertingImages.PNG; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.ResolutionSetting; 10 | import com.aspose.psd.examples.Utils.Utils; 11 | import com.aspose.psd.fileformats.psd.PsdImage; 12 | import com.aspose.psd.imageoptions.PngOptions; 13 | 14 | /** 15 | * 16 | * 17 | */ 18 | public class SettingResolution { 19 | public static void main(String[] args) 20 | { 21 | //ExStart:SettingResolution 22 | String dataDir = Utils.getDataDir(SettingResolution.class) + "ModifyingAndConvertingImages/"; 23 | 24 | PsdImage psdImage = (PsdImage)Image.load(dataDir + "sample.psd"); 25 | 26 | // Create an instance of PngOptions, Set the horizontal & vertical resolutions and Save the result on disc 27 | PngOptions options = new PngOptions(); 28 | options.setResolutionSettings(new ResolutionSetting(72, 96)); 29 | psdImage.save(dataDir+"SettingResolution_output.png", options); 30 | //ExEnd:SettingResolution 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PNG/SpecifyBitDepth.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.ModifyingAndConvertingImages.PNG; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.examples.Utils.Utils; 10 | import com.aspose.psd.fileformats.png.PngColorType; 11 | import com.aspose.psd.fileformats.psd.PsdImage; 12 | import com.aspose.psd.imageoptions.PngOptions; 13 | 14 | /** 15 | * 16 | * 17 | */ 18 | public class SpecifyBitDepth { 19 | public static void main(String[] args) 20 | { 21 | //ExStart:SpecifyBitDepth 22 | String dataDir = Utils.getDataDir(SpecifyBitDepth.class) + "ModifyingAndConvertingImages/"; 23 | 24 | PsdImage psdImage = (PsdImage)Image.load(dataDir + "sample.psd"); 25 | // Create an instance of PngOptions, Set the desired ColorType, BitDepth according to the specified ColorType and save image 26 | PngOptions options = new PngOptions(); 27 | options.setColorType(PngColorType.Grayscale); 28 | options.setBitDepth((byte)1); 29 | psdImage.save(dataDir+"SpecifyBitDepth_out.png", options); 30 | //ExEnd:SpecifyBitDepth 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PNG/SpecifyTransparency.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.ModifyingAndConvertingImages.PNG; 7 | 8 | import com.aspose.psd.Color; 9 | import com.aspose.psd.Image; 10 | import com.aspose.psd.examples.Utils.Utils; 11 | import com.aspose.psd.fileformats.psd.PsdImage; 12 | 13 | 14 | public class SpecifyTransparency { 15 | public static void main(String[] args) 16 | { 17 | //ExStart:SpecifyTransparency 18 | String dataDir = Utils.getDataDir(SpecifyTransparency.class) + "ModifyingAndConvertingImages/"; 19 | 20 | PsdImage psdImage = (PsdImage)Image.load(dataDir + "sample.psd"); 21 | 22 | // Initialize PNG image with psd image pixel data. 23 | PsdImage pngImage = new PsdImage(psdImage); 24 | 25 | // specify the PNG image transparency options and save to file. 26 | pngImage.setTransparentColor(Color.getWhite()); 27 | pngImage.setTransparentColor(true); 28 | pngImage.save(dataDir+"Specify_Transparency_result.png"); 29 | //ExEnd:SpecifyTransparency 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSB/PSBToJPG.java: -------------------------------------------------------------------------------- 1 | 2 | package com.aspose.psd.examples.ModifyingAndConvertingImages.PSB; 3 | 4 | import com.aspose.psd.Image; 5 | import com.aspose.psd.examples.Utils.Utils; 6 | import com.aspose.psd.fileformats.psd.PsdImage; 7 | import com.aspose.psd.imageloadoptions.PsdLoadOptions; 8 | import com.aspose.psd.imageoptions.JpegOptions; 9 | 10 | 11 | public class PSBToJPG { 12 | 13 | public static void main(String[] args) 14 | { 15 | //ExStart:PSBToJPG 16 | String dataDir = Utils.getDataDir(PSBToJPG.class) + "PSB/"; 17 | 18 | String sourceFileName = dataDir + "Simple.psb"; 19 | 20 | PsdLoadOptions options = new PsdLoadOptions(); 21 | PsdImage image = (PsdImage)Image.load(sourceFileName, options); 22 | 23 | JpegOptions jpgoptions = new JpegOptions(); 24 | jpgoptions.setQuality(95); 25 | 26 | // All jpeg and psd files must be readable 27 | image.save(dataDir + "Simple_output.jpg",jpgoptions); 28 | image.save(dataDir + "Simple_output.psb"); 29 | //ExEnd:PSBToJPG 30 | 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSB/PSBToPDF.java: -------------------------------------------------------------------------------- 1 | 2 | package com.aspose.psd.examples.ModifyingAndConvertingImages.PSB; 3 | 4 | import com.aspose.psd.Image; 5 | import com.aspose.psd.examples.Utils.Utils; 6 | import com.aspose.psd.fileformats.psd.PsdImage; 7 | import com.aspose.psd.imageoptions.PdfOptions; 8 | 9 | 10 | public class PSBToPDF { 11 | 12 | public static void main(String[] args) 13 | { 14 | //ExStart:PSBToPDF 15 | String dataDir = Utils.getDataDir(PSBToPDF.class) + "PSB/"; 16 | String sourceFileName = dataDir + "Simple.psb"; 17 | 18 | 19 | PsdImage image = (PsdImage)Image.load(sourceFileName); 20 | 21 | image.save(dataDir + "Simple_output.pdf",new PdfOptions()); 22 | 23 | //ExEnd:PSBToPDF 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSB/PSBToPSD.java: -------------------------------------------------------------------------------- 1 | 2 | package com.aspose.psd.examples.ModifyingAndConvertingImages.PSB; 3 | 4 | import com.aspose.psd.Image; 5 | import com.aspose.psd.examples.Utils.Utils; 6 | import com.aspose.psd.fileformats.psd.FileFormatVersion; 7 | import com.aspose.psd.fileformats.psd.PsdImage; 8 | import com.aspose.psd.imageoptions.PsdOptions; 9 | 10 | 11 | public class PSBToPSD { 12 | public static void main(String[] args) 13 | { 14 | //ExStart:PSBToPSD 15 | String dataDir = Utils.getDataDir(PSBToPSD.class) + "PSB/"; 16 | String sourceFileName = dataDir + "2layers.psb"; 17 | 18 | 19 | PsdImage image = (PsdImage)Image.load(sourceFileName); 20 | 21 | PsdOptions options = new PsdOptions(); 22 | options.setFileFormatVersion(FileFormatVersion.Psd); 23 | 24 | image.save(dataDir + "ConvertFromPsb_out.psd",options); 25 | 26 | //ExEnd:PSBToPSD 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/AddTextLayerOnRuntime.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.ModifyingAndConvertingImages.PSD; 7 | 8 | import com.aspose.psd.Image; 9 | import com.aspose.psd.Rectangle; 10 | import com.aspose.psd.examples.Utils.Utils; 11 | import com.aspose.psd.fileformats.psd.PsdImage; 12 | import com.aspose.psd.fileformats.psd.layers.TextLayer; 13 | 14 | /** 15 | * 16 | * 17 | */ 18 | public class AddTextLayerOnRuntime { 19 | 20 | public static void main(String[] args) 21 | { 22 | //ExStart:AddTextLayerOnRuntime 23 | String dataDir = Utils.getDataDir(AddTextLayerOnRuntime.class) + "PSD/"; 24 | 25 | 26 | String sourceFileName = dataDir+"OneLayer.psd"; 27 | String psdPath = dataDir + "ImageWithTextLayer.psd"; 28 | 29 | Image img = Image.load(sourceFileName); 30 | 31 | PsdImage im = (PsdImage)img; 32 | Rectangle rect = new Rectangle( 33 | (int)(im.getWidth() * 0.25), 34 | (int)(im.getHeight() * 0.25), 35 | (int)(im.getWidth() * 0.5), 36 | (int)(im.getHeight() * 0.5)); 37 | 38 | TextLayer layer = im.addTextLayer("Added text", rect); 39 | 40 | im.save(psdPath); 41 | 42 | //ExEnd:AddTextLayerOnRuntime 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/ChangeBlendModeInGradientOverlayEffect.java: -------------------------------------------------------------------------------- 1 | package com.aspose.psd.examples.ModifyingAndConvertingImages.PSD; 2 | 3 | import com.aspose.psd.Image; 4 | import com.aspose.psd.examples.Utils.Utils; 5 | import com.aspose.psd.fileformats.psd.PsdImage; 6 | import com.aspose.psd.fileformats.psd.layers.BlendMode; 7 | import com.aspose.psd.fileformats.psd.layers.layereffects.GradientOverlayEffect; 8 | 9 | /** 10 | * An example of changing the blending mode for a gradient overlay effect. 11 | */ 12 | public class ChangeBlendModeInGradientOverlayEffect 13 | { 14 | public static void main(String[] args) 15 | { 16 | //ExStart:ChangeBlendModeInGradientOverlayEffect 17 | String sourceDir = Utils.GetDataDir_PSD(); 18 | String outputDir = Utils.GetDataDir_Output(); 19 | 20 | String inPsdFilePath = sourceDir + "psdnet585.psd"; 21 | String outPsdFilePath = outputDir + "out_psdnet585.psd"; 22 | 23 | // Load a PSD file containing an image layer 24 | PsdImage psdImage = (PsdImage)Image.load(inPsdFilePath); 25 | try 26 | { 27 | GradientOverlayEffect gradientOverlayEffect = 28 | psdImage.getLayers()[1].getBlendingOptions().addGradientOverlay(); 29 | 30 | // Change the blend mode for the gradient overlay effect 31 | gradientOverlayEffect.setBlendMode(BlendMode.Subtract); 32 | 33 | // Save a modified copy of loaded PSD file on the path 34 | psdImage.save(outPsdFilePath); 35 | } 36 | finally 37 | { 38 | psdImage.dispose(); 39 | } 40 | //ExEnd:ChangeBlendModeInGradientOverlayEffect 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Examples/src/main/java/com/aspose/psd/examples/ModifyingAndConvertingImages/PSD/ColorReplacementInPSD.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.aspose.psd.examples.ModifyingAndConvertingImages.PSD; 7 | 8 | import com.aspose.psd.Color; 9 | import com.aspose.psd.Image; 10 | import com.aspose.psd.examples.Utils.Utils; 11 | import com.aspose.psd.fileformats.psd.PsdImage; 12 | import com.aspose.psd.fileformats.psd.layers.Layer; 13 | 14 | import java.util.Objects; 15 | 16 | /** 17 | * 18 | * 19 | */ 20 | public class ColorReplacementInPSD { 21 | 22 | public static void main(String[] args) 23 | { 24 | //ExStart:ColorReplacementInPSD 25 | String dataDir = Utils.getDataDir(ColorReplacementInPSD.class) + "PSD/"; 26 | 27 | // Load a PSD file as an image and caste it into PsdImage 28 | PsdImage image = (PsdImage)Image.load(dataDir + "sample.psd"); 29 | 30 | for (int i =0; i