Consulting

Results 1 to 8 of 8

Thread: Exporting images with bit depth of 32

  1. #1
    VBAX Newbie
    Joined
    Sep 2018
    Posts
    4
    Location

    Exporting images with bit depth of 32

    Using PP2016, I have a macro that exports images as png files but the quality is much poorer than if I save each image individually - I tried various parameters but they didn't seem to make any difference. I notice that individually-saved images have a bit depth of 32 while the vba ones' is only 24. Assuming that the greater bit depth will improve the quality of the image is there a way to make the images export with a bit depth of 32? I wonder why the different method of saving results in different bit depths.

    My current code is below.

    Sub SaveImages()
    Dim oPresentation As Presentation
    Dim oSlide As Slide
    Dim oShape As Shape
    Dim sFilename As String
    Dim sPath As String
    Dim sli As Integer
    Dim shi As Integer


    Set oPresentation = ActivePresentation

    For Each oSlide In oPresentation.Slides
    sli = oSlide.SlideNumber
    For Each oShape In oSlide.Shapes
    If oShape.Type = msoGroup Then
    shi = oShape.Id

    sFilename = sli & "-" & shi & ".png"
    sPath = "C:\Users\User\Pictures\pp" & sFilename
    Call oShape.Export(sPath, ppSaveAsPNG)
    End If
    Next
    Next
    End Sub

  2. #2
    VBAX Newbie
    Joined
    Sep 2018
    Posts
    4
    Location
    Actually, I discovered that you can change the file extension to zip which will automatically save the images in a folder named "media". The quality is fantastic but the bit depth is still only 24 so obviously the problem isn't the bit depth. The trouble is that it saves the images only (and the full-size image not the cropped image if it is cropped), not the grouped objects which is what I want to save, however, if you have images only with no shapes added, changing the file extension is a great way to extract images.

  3. #3
    VBAX Master
    Joined
    Feb 2007
    Posts
    1,697
    Location
    Does this give similar quality to manually exported pics?

    Sub ex_Me()
    Dim oshp As Shape
    
    Dim sH As Single
    Dim sW As Single
    Set oshp = ActiveWindow.Selection.ShapeRange(1)
    sH = 1.566 * ActivePresentation.PageSetup.SlideHeight 
    sW = 1.566 * ActivePresentation.PageSetup.SlideWidth 
    Call oshp.Export(Environ("USERPROFILE") & "\Desktop\test.png", ppShapeFormatPNG, _
    sW , _
    sH , ppRelativeToSlide)
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  4. #4
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    3,607
    Location
    Whether you extract an image through the GUI or via VBA has no effect on the bit depth; a 24-bit image won't suddenly gain 8 bits of colour depth via the GUI; the opposite is also true.

    Frankly, I seriously doubt you or anyone else could tell the difference in image-quality between a 24-bit image and a 32-bit one. A 24-bit depth gives 16,777,216 colour variations but the human eye can only discriminate up to 10,000,000 colours. Higher bit depths are only used for image editing, not viewing.

    Rather, your problem seems to be related to image resolution, which is an entirely different matter from bit depth. Image resolution is affected by, amongst other things, whether you have allowed PPT to compress the images. Similarly, cropping, etc. can be taken care of by the 'discard editing data' setting.
    Cheers
    Paul Edstein
    [MS MVP - Word]

  5. #5
    VBAX Newbie
    Joined
    Sep 2018
    Posts
    4
    Location
    Eureka! You are a total legend, John. I was convinced there was nothing out there but your code produces a beautiful image, which, funnily enough has a bit depth of 32 even if, as Paul points out, this would hardly make a difference. Thank you so very much. This will make the job at hand sooooooo much quicker.

  6. #6
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    3,607
    Location
    All John's code does is increase the image's size as displayed in PowerPoint before copying; it does nothing to the underlying image resolution or bit depth...
    Cheers
    Paul Edstein
    [MS MVP - Word]

  7. #7
    VBAX Master
    Joined
    Feb 2007
    Posts
    1,697
    Location
    It doesn't change the bit depth but it does increase to export size (not by changing the size on slide)
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  8. #8
    VBAX Master
    Joined
    Feb 2007
    Posts
    1,697
    Location
    ​Strangely it does change the bit depth here from 24 to 32.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •