[SOLVED] Converting psd files to png lazarus / 39-Graphics ---------------------------------------------------------------------- SaraT · 2025-04-19 06:25 Hi coders, There is a unit called FPReadPSD, but there is not enough information about reading .psd files :/ Does anybody have a working example to read .psd files and convert to .png? I would be so thankful if somebody provide me a code to make this works. Please and thanks. ---------------------------------------------------------------------- TRon · 2025-04-19 07:14 unit FPReadPSD reference. wiki snippet converting from one raster format to another using fp(memory)image. Are you able to manage that ? ---------------------------------------------------------------------- SaraT · 2025-04-19 07:27 Quote from: TRon on April 19, 2025, 09:14:11 amAre you able to manage that ? Sorry, TRon, but Im not able... this is the first time I see the FPReadPSD unit and have not worked converting this type of file. Maybe someone else could share a working code. Hope this unit can save with transparent png too. Thanks for your answer. ---------------------------------------------------------------------- TRon · 2025-04-19 07:40 No problem SaraT here we go: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program test; {$mode objfpc}{$h+} {  references:  - thread "Converting psd files to png"    https://forum.lazarus.freepascal.org/index.php/topic,70870.0.html   - sample psd files    https://customerscanvas.com/help/designers- manual/adobe/photoshop/gallery.html   - fcl-image wiki snippet    https://wiki.freepascal.org/fcl- image#Converting_between_two_raster_image_formats   - readpsd unit reference    https://www.freepascal.org/daily/packages/fcl- image/fpreadpsd/index-4.html} uses  sysutils, fpImage, fpreadpsd, fpwritepng; procedure processFile(Filename: string);var  image  : TFPCustomImage;  reader : TFPCustomImageReader;  writer : TFPCustomImageWriter;begin  Image  := TFPMemoryImage.Create(10, 10);  Reader := TFPReaderPSD.Create;  Writer := TFPWriterPNG.Create;  Image.LoadFromFile(FileName, Reader);  Filename := ChangeFileExt(Filename, '.png');  Image.SaveToFile(Filename, Writer);end; var  Filename : string = 'placeholders-with- frames.psd';begin  if FileExists(Filename)    then ProcessFile(Filename)end.  I have no idea about transparency. PSD is not really something I use on a regular base. ---------------------------------------------------------------------- SaraT · 2025-04-19 14:29 Quote from: TRon on April 19, 2025, 09:40:03 amNo problem SaraT here we go: Thanks a lot, TRon. ---------------------------------------------------------------------- TRon · 2025-04-19 16:58 You're welcome SaraT. Note that the example code did not free the created instances of reader, writer and image (FUAI). You'd need to correct that when using the example in production code.