Changing a screenshot to JPG instead of PNG

I've got a script that works that runs on a scheduled task to snapshot the screen of a computer.  Basically the computer runs a query at a regular interval that is pretty resource intensive on the server but has information that anyone might want to
see at a given time.  So rather than having them generate the data on the fly, they get a html page that displays the screenshot of the last result set. The script is based on another one that I found online.  Right now it saves in PNG format and
is about 1.8MB.  I'm trying to get it to save in .JPG format so it is smaller.  
This works:
$ScreenshotObject.Save($FilePath)
However this does not:
$ScreenshotObject.Save($JpgOut, Drawing.Imaging.ImageFormat.Jpeg))
I'm about 90% sure my problem lies in the Drawing.Imaging.ImageFormat.Jpeg part.  I guess I'm not sure what the correct parameter is since there seem to be many things that can end in .ImageFormat.Jpeg.  I've tried Drawing.Bitmap.ImageFormat.Jpeg.
I've tried with System at the beginning. I've also tried Drawing.Grapics.ImageFormat.Jpeg
I've also tried several variations on New-Object and various ways of trying to save it.
I guess I just can't figure out which is the right way.
The errors vary from Cannot find Type, or complaining that I passed a null value.
$ImageFormat = New-Object [Drawing.Imaging.ImageFormat]::Jpeg
$ImageFormat = New-Object [Drawing.Imaging]::ImageFormat.Jpeg
$ImageFormat = New-Object [Drawing.Imaging]::ImageFormat
$ScreenshotObject.Save("C:\Screenshot\Current.Jpg",$ImageFormat.Jpeg)
$ScreenshotObject.Save("C:\Screenshot\Current.Jpg",$ImageFormat)
And I've tried with and without:
Add-Type -Assembly System.Drawing.Imaging
Here's the full script.  I've alternated between commenting out the first save and uncommenting the second.
Again, just saving it with a default path outputs it in PNG format and works.  It's just 1.8MB is a lot to put in a web page the that keeps refreshing.
$Path = "c:\Screenshot"
$Current = "Current.Png"
$CurrentJpg = "Current.Jpg"
$JpgOut = (Join-Path $Path $CurrentJpg)
Function GenScreenshot
$ScreenBounds = [Windows.Forms.SystemInformation]::VirtualScreen
$ScreenshotObject = New-Object Drawing.Bitmap $ScreenBounds.Width, $ScreenBounds.Height
$DrawingGraphics = [Drawing.Graphics]::FromImage($ScreenshotObject)
$DrawingGraphics.CopyFromScreen( $ScreenBounds.Location, [Drawing.Point]::Empty, $ScreenBounds.Size)
$DrawingGraphics.Dispose()
$ScreenshotObject.Save($FilePath)
#$ScreenshotObject.Save("C:\Screenshot\Current.Jpg", Drawing.Imaging.ImageFormat.Jpeg))
$ScreenshotObject.Dispose()
Add-Type -Assembly System.Windows.Forms
$Time = (Get-Date)
[string] $FileName = "$($Env:ComputerName)"
$FileName += '-'
$FileName += "$($Time.Hour)"
$FileName += '-'
$FileName += "$($Time.Minute)"
$FileName += '.png'
[string] $FilePath = (Join-Path $Path $FileName)
Remove-Item $FilePath
GenScreenshot
Copy-Item $FilePath -destination (Join-Path $Path $Current)

I think this is loser to what you are trying to do:
Function GenScreenshot{
param(
$ImageFile,
$ImageFormat='Jpeg'
Begin{
Add-Type -Assembly System.Windows.Forms
Process{
$ScreenBounds = [Windows.Forms.SystemInformation]::VirtualScreen
$ScreenshotObject = New-Object Drawing.Bitmap $ScreenBounds.Width, $ScreenBounds.Height
$DrawingGraphics = [Drawing.Graphics]::FromImage($ScreenshotObject)
$DrawingGraphics.CopyFromScreen( $ScreenBounds.Location, [Drawing.Point]::Empty, $ScreenBounds.Size)
$DrawingGraphics.Dispose()
$ScreenshotObject.Save($imagefile,[System.Drawing.Imaging.ImageFormat]$ImageFormat)
$ScreenshotObject.Dispose()
$path='c:\screenshot'
$FileName='{0}\{1} {2:hh-mm}.jpg' -f $Path, $Env:ComputerName,[datetime]::Now
Remove-Item $filename -ea 0
GenScreenshot -ImageFile $filename
Invoke-Item $filename
\_(ツ)_/

Similar Messages

  • How may I make my screen shots default to a .jpg instead of .png

    How may I make my screen shots default to a .jpg instead of .png?
    Is there a preference somewhere?

    One easy way is:
    Changing the File Format
    In order to change the file format you must firstly open up a Terminal window (Applications/Utilities/Terminal.app), and type the following.
    defaults write com.apple.screencapture type TYPE
    For the command to work, you need to replace “TYPE” with a valid file format, the available options are:
    png (default)
    pdf
    jpg
    jp[2 (jpeg 2000)
    gif
    tiff
    bmp
    pict
    tga
    Once you have selected your format simply issues the command, placing the file format in it’s space. For example for a JPG, I would issue:
    defaults write com.apple.screencapture type jpg

  • IWeb 08 - publishing images as .jpg instead of .png? is that possible?

    Dear all,
    I have created a website and it recently gone too big.
    I notice the .png files is getting too huge and it would be much smaller if it is in .jpg (due to the background images).
    Could any1 advise me if there is a setting option to publish the images to a .jpg or .gif?
    Thanks!

    Are these background images part of a theme or ones that you have added yourself?

  • How to change a video to jpg?

    I mistakenly had the button on my Canon PowerShot A300 switched to video when I took four pictures. I didn't notice it until I uploaded the pictures into iPhoto 6. Is there any way I can change the images to jpg instead of mvi? I want to use the photos on my desktop, and they won't come up if they are mvi.
    Thanks,
    Joanne
    Message was edited by: Joanne Walen

    My apologies. I just tried it myself, and even though I selected to export the jpeg, it still exported the complete video file. Weird. I have no idea why this is happening.
    There is another way to get that still image, but you'll have to be very careful. iPhoto automatically creates a jpeg version of each video file for displaying in your library. If you right-click (control-click) on the thumbnail and select "Show File" a Finder window should open with the video file selected. Set the Finder window to Column view, and you can clearly trace its path in the iPhoto Library/ Originals folder. The jpeg of the first frame will be stored in an analogous location inside the iPhoto Library/ Modified folder. (Same Roll name, same file name, except for the .jpg extension). Locate the jpeg in the Modified folder, select it and do a File > Duplicate command. Move the copy to another location outside of the iPhoto Library.
    I would be irresponsible if I failed to give you the standard warning about messing around inside the iPhoto Library folder. Warning: Be careful that you don't change any of the items inside there, or you can damage your database. Just select the file, duplicate it, and move the copy out. If you move the file that iPhoto knows about, you will have problems with your iPhoto Library.
    Regards.

  • Screenshots stored as .PNG instead of .png

    I have no idea how it happen, but all the sudden Grab stores my screenshots in .PNG instead of .png. Same happens when I use Cmd–Shift–3.
    Does anyone know how to change this setting?

    I just deleted ~/Library/Preferences/com.apple.screencapture.plist, and the problem was resolved after loging out and back in again.
    I hope this will help someone else searching for a solution to the capitalised file extension problem.

  • My iphone 5s is taking screenshots in jpg. I would like them to be png but cannot find a setting for this....

    My iphone 5s is taking screenshots in jpg. I would like them to be png but cannot find a setting for this....

    Wrong forum. Here you have "Adobe Reader".
    For Flash Player visit:
    https://forums.adobe.com/community/flashplayer
    From this you can use the links to the sub-forums for Installing Flash Player and Using Flash Player.
    Good to know is that no password is needed to download, install and use Flash Player. 
    For the Acrobat / Adobe Reader Flsh Player see:
    https://helpx.adobe.com/acrobat/using/flash-player-needed-acrobat-reader.html
    Be well...

  • HT2335 My iphone 4S previously saved photos in the jpg format.  Suddenly it changed to the bmp format.  How do I change it back to jpg?

    My iphone 4S previously saved photos in the jpg format.  Suddenly it changed to the bmp format.  How do I change it back to jpg?

    Photos captured by the iPhone are saved in jpeg format. A screen capture is saved in png format.
    There is no setting to change either one to be captured/saved in a different format.

  • Importing jpgs instead of RAW...

    I've just imported my 3rd CF card into lightroom 4. The first one had no problems but with the 2nd and third I have noticed that about 200+ photos in it starts importing the occassional jpg instead of the .CR2 file? By the end of the import it seems to be every second or thirtd file but random not consistent. I have been shooting in both RAW and JPG lately which was never a problem in LR3 - it would only ever import the RAW files in to LR - it would import the JPGs but just to the hard disk. I only noticed when editing and realising that I wasn't getting all the WB options on some of the files...
    Anyone alse having this issue? any suggesitons?
    Thanks

    Thanks for the reply Lee
    I hadn't changed the import setting at all from the default (always worked
    ok in LR3). The strange thing is that it has imported all the pics in
    sequence 321,322 but only some of them are JPEGs - completely random. I
    checked the drive where they were imported and it has imported about 2/3
    RAW and 1/3 JPEG so I checked the card to make sure something weird hadn't
    happened to it and sure enough the card contains all the RAW and JPG files.
    I had already started editing about a third of the files before I realised
    so I did a new import using LR3 and then deleted the import from LR4 and
    then did the 'find file' thingy in LR4 which still found the JPGs.. so I
    moved the JPGs to another folder and did the 'find file' thingy again and
    this time had to select the matching RAW file... quite time consuming but
    it worked!
    Just wondering if this is a bug? It didn't happen with the previous import
    with all settings the same.
    Thanks again

  • Make iTunes save artworks in JPEG instead of PNG

    Hey all,
    one little question:
    Is it possible to make iTunes save the artworks as JPEG in the audio file instead of PNG?
    Thanks!

    Clearly they don't have the requirements you do.
    There's nothing wrong with saving JPEGs.  I happen to need them all the time as well, and prior to getting CS5 I always found myself changing the mode to 8 bits, saving as JPEG, then (if I remembered) going back in the history to where the document was 16 bits.
    When I asked about saving PSD files I didn't realize you needed JPEGs for specific purposes.
    -Noel

  • How to change the color of letters instead of highlight the text when compare two documents

    Hello!!
    I have the Adobe Acrobat 9 Pro (Versión 9.0.0) and I need to compare two documents, but I want to show the diferences changing  the color of letters instead of highlight the text with any color. My boss tell me that other Acrobat version have this option, but I couldn't find it in this version.
    Could you help me on this topic??
    Thanks

    Hello!!
    I have the Adobe Acrobat 9 Pro (Versión 9.0.0) and I need to compare two documents, but I want to show the diferences changing  the color of letters instead of highlight the text with any color. My boss tell me that other Acrobat version have this option, but I couldn't find it in this version.
    Could you help me on this topic??
    Thanks

  • I have many thousands of songs in my itunes library. Unfortunately, most are now pointing toward .jpgs instead of the m4a files in my itunes library. Is there anyway to fix this without reimporting all the files into itunes from scratch??

    I have many thousands of songs in my itunes library. Unfortunately, most are now pointing toward .jpgs instead of the m4a files in my itunes library. Is there anyway to fix this without reimporting all the files into itunes from scratch?

    OMG...I'm glad to know I'm not the only one. Since my computer is a goner, I don't have any other way to access all that music.

  • I am trying to set up app tabs, but when I am using one, if I go to a new site from there, the app tab changes to the new site instead of opening in a new tab, then the app tab changes to the new site. Can you help? Thanks

    I am trying to set up app tabs, but when I am using one, if I go to a new site from there, the app tab changes to the new site instead of opening in a new tab, then the app tab changes to the new site. i.e. The app tabs don't stay constant. This occurs while still in Firefox, and does not relate to when I close it. Has anyone got any ideas? Thanks

    If you backed up the iPhone to either iTunes or the iCloud, restore the backup. If not, the data is gone.
    (126342)

  • Photos recently changed from sequential numbering to date/timestamp.  When I import into apps for editing they are out of order.  What can be done to change back to sequential numbering instead of date/timestamp?

    Photos recently changed from sequential numbering to date/timestamp.  When I import into apps for editing they are out of order.  What can be done to change back to sequential numbering instead of date/timestamp?

    The date information is taken from the camera which writes it to the file. This needs to be set to the correct date and time in the camera itself.
    The order the images are shown in the Library mode is set by clicking on the sort button in the tool bar, which if not showing can be activated from view, tool bar. There are different sort orders that can be applied including sorting by file name. You can also sort by dragging the images to the order you wish them to appear in by selecting user order.

  • How do I change pdf to a jpg?

    How do I change pdf to a jpg?

    Adobe Reader cannot do this. Adobe Acrobat can.
    Also, there may be some free online convertors out there if you Google them.

  • Saving logos as jpg, eps, and png. What mode do I create each in? RGB or CMYK?

    Question... My client has asked for their logo as a JPG, EPS and PNG. They want a file ready to go, so they can fire off logos to whomever for whatever purpose.
    The Pantones are selected. My question, what mode do I create each format (jpg, eps, png) in? CMYK or RGB? Or do I create a CMYK and RGB of each for each format? (The more I know, the less I understand)

    Wow, thanks for your input. I also spoke with a printer with whom I'm working on another job.
    I think I've really over-complicated this, and here's all I really need to send them:
    EPS: Pantone, CMYK, RGB (I have read EPS's are outdated, but she didn't have a problem with it. This way they can take the Pantone colors and try to replicate them as closely as possible)
    JPG: Pantone, CMYK, RGB (per your earlier comments)
    PNG: Pantone, RGB (Web usage)
    PDF/X-4: Printer didn't have strong feelings on this format. She said the EPS would be fine. I'll still send it though.
    Sound good? (I like affirmation)

Maybe you are looking for

  • How many computers can I install Acrobat XI on?

    I will be purchasing Acrobat XI Pro and need to know how many computers it can be installed on.

  • Error 500--Internal Server Error  org.apache.tapestry

    Hi. I am getting the following error when access an application. Application give no error during deployment. Only get this error when trying to logon to the application. How do I resolve this issue? Thanks Sayef Error 500--Internal Server Error org.

  • ITune sync is not well designed on PC for basic users

    Hi, I don't have a iPhone, I'm the guy people call when they have computer problems. One of this person have lost all is iPhone contacts and agenda. He tried to sync with Outlook but did it the wrong way, replacing empty Outlook contact and agenda on

  • Auto Discover Not Work Well on Japanese OS

    Hello, We are running at Exchange 2007 SP3 RU5, most clients are domain members with Windows 7 English version and autodiscover is working very well. But, the remote office in Japan who is using Japanese Windows 7/ XP cannot use autodiscover for auto

  • InfoSource activation issue

    Hi gurus! I tried to activate an infosource but the system shows an error: Error generating program Message no. RSAR245 Diagnosis An error occurred during program generation: Template:   RSTMPL80 Error code: 6 Row:        47 Message:    Statement con