1
Vote

Export-Bitmap random problems with GDI

description

This works:
Import-Bitmap file.jpg | Export-Bitmap -Path file.jpeg
 
This doesn't:
 
[37]: $bitmap = Import-Bitmap cold_welcome_1440x900.jpg
[38]: Export-Bitmap -Bitmap $bitmap -Path foo.jpeg
Export-Bitmap : A generic error occurred in GDI+.
39: $Error[0].Exception
A generic error occurred in GDI+.
40: $Error[0].Exception.StackTrace
at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
at Pscx.Commands.Drawing.ExportBitmapCommand.<>c__DisplayClass1.<ProcessBitmap>b__0(Stream stream)
at Pscx.Commands.PscxCmdlet.Pscx.Commands.IPscxFileHandler.ProcessWrite(String filePath, Action`1 action)
at Pscx.Commands.Drawing.ExportBitmapCommand.ProcessBitmap(Bitmap bitmap)
at System.Management.Automation.CommandProcessor.ProcessRecord()
 
 
I can't figure it out, but this does work:
 
[49]: $bitmap = Import-Bitmap cold_welcome_1440x900.jpg | Resize-Bitmap -Percent 100
[50]: $bitmap | Export-Bitmap -Path foo.jpeg

comments