How to Set DPI/Resolution When Converting PSD Files in .NET
For print, prepress, and high-res digital workflows, setting DPI (dots per inch) is critical. Aspose.PSD for .NET lets you define custom DPI/output resolution for any PSD conversion (JPEG, PNG, TIFF, PDF, etc.) with a single line of code.
Real-World Problem
Default DPI is rarely suitable for publishing or print. Manual export requires too many clicks and can’t scale for large image sets.
Solution Overview
Configure your chosen ImageOptions
(e.g., JpegOptions
, PngOptions
, TiffOptions
, PdfOptions
) to set the exact DPI needed, then save the converted file.
Prerequisites
- Visual Studio 2019 or later
- .NET 6.0 or later (or .NET Framework 4.6.2+)
- Aspose.PSD for .NET from NuGet
- PSD file(s) for conversion
PM> Install-Package Aspose.PSD
Step-by-Step Implementation
Step 1: Load the PSD File
using Aspose.PSD;
using Aspose.PSD.FileFormats.Psd;
using Aspose.PSD.ImageOptions;
string inputFile = "./input/hires.psd";
string outputFile = "./output/hires.jpg";
var loadOptions = new PsdLoadOptions() { LoadEffectsResource = true };
PsdImage image = (PsdImage)Image.Load(inputFile, loadOptions);
Step 2: Set DPI in Export Options
var jpegOptions = new JpegOptions()
{
ResolutionSettings = new ResolutionSetting(300, 300) // 300x300 DPI for print quality
};
Step 3: Save the File with Custom DPI
image.Save(outputFile, jpegOptions);
image.Dispose();
Use Cases and Applications
- Print-ready or high-res marketing assets
- Prepress or design-to-print workflows
- Web assets with specific pixel density requirements
Common Challenges and Solutions
DPI ignored in some viewers: Some software ignores DPI and uses pixel dimensions only—test in print and professional workflows.
Wrong output size: Always check both pixel dimensions and DPI in output file properties.
Best Practices
- Always preview in your print or digital workflow
- Use 300+ DPI for print, 72–150 DPI for web
- Automate for full image libraries as needed
FAQ
Q: Can I set DPI for all output formats?
A: Yes—use the corresponding ImageOptions
class and set ResolutionSettings
.
Q: Does changing DPI change pixel dimensions? A: No—DPI metadata is separate from image size; adjust both if needed.
Conclusion
Aspose.PSD for .NET gives you total control over image resolution for every output format. For more advanced conversion and DPI features, see the Aspose.PSD for .NET API Reference .