How to convert PNG with transparency to PSD


#1

Hi, I have been trying to convert a PNG to a PSD while preserving the transparent background, but have been struggling to get the library to not make the transparent areas black. Am I just missing something or is this the expected behaviour?


#2

@Donato381,

Can you please share source file so that we may further investigate to help you out.


#3

Hi @Adnan.Ahmad
people_clipped_rev_3.png (141.4 KB)
Here is the PNG file I am attempting to convert into a PSD. I also need to insert a little metadata like the author and edit date. I have managed to get the file to convert with the metadata inserted but the transparency always turns black upon converting. If you could point me in the right direction for getting the transparency to persist I would greatly appreciate it.


#4

@Donato381,

Can you please try to use following code snippet on your end. Also please try to open generated file in Photoshop to see the transparency.

string dataDir = “F:\Aspose Work\”;

  	using (PngImage iimage =(PngImage)Image.Load(dataDir+"people_clipped_rev_3.png"))
  	{

  		using (PsdImage image = new PsdImage(iimage.Width, iimage.Height))
  		{
  			Layer layer = new Layer(iimage);
  			image.AddLayer(layer);
  			image.Save(dataDir+"people_clipped_rev_3.psd", new PsdOptions() { });
  		}
  	}

#5

@Adnan.Ahmad

I am having a little trouble implementing the code you provided. On my end I cannot Initialise ‘Layer’ with iimage and ‘PsdImage image’ does not contain a method for AddLayer.


#6

@Donato381,

I like to inform that AddLayer was added in 19.11 release assembly which will be released in the beginning of November. I request for your patience.


#7

Hi @Adnan.Ahmad

So the code you provided will work on the new release?
If that is the case I will gladly wait until the next release.

Thanks for the assistance.


#8

@Donato381,

Yes, this will work in 19.11.