Awesome, thank you so much for that info. That makes my tail chasing make
more sense! Thanks for saving me from additional posterior extension
pursuit.

Last question I think, how do I put a file path reference on the clipboard
similar to in explorer selecting a few files and hitting control c ?

I think I had tested that with discord and it worked, but not 100% on that.

On Thu, Aug 12, 2021, 11:57 AM Tim Roberts <t...@probo.com> wrote:

> Mriswithe wrote:
> >
> > I was looking at making a little helper app for Windows that will take
> > an image on your clipboard and ensure it is under 8MB for posting to
> > discord, and if it isn't, use Pillow to resize it until it is the
> > right size.
> >
> > I can use Pillow's ImageGrab.grabclipboard() to get the image off the
> > clipboard, but I am a little confused about writing it back. I have
> > been back and forth between the pywin32 source and the windows docs
> > for the windows C API, but I don't have any previous experience or
> > context to know what some pieces are intended to do.
> >
> > I found an example to write to it from StackOverflow
> > (https://stackoverflow.com/questions/34322132/copy-image-to-clipboard
> > <https://stackoverflow.com/questions/34322132/copy-image-to-clipboard>),
>
> > but I was wanting to dig a little deeper to see what formats other
> > than BMP I could use to put on the clipboard. My ignorance of C++ and
> > the Windows APIs and hell the Python C API is really biting me here.
>
> You can't.  You have to write it as a DIB (Device Independent Bitmap),
> which is the format in a .BMP file.
>
> The Windows clipboard was designed in roughly 1986, before GIF, before
> JPEG and way, way before PNG.  The clipboard is designed for universal
> interchange, so it really does need to spec the lowest common
> denominator.  If they allowed PNGs, then all of the graphics application
> in the world would have to be modified to decode PNG data.
>
> So, to make your app work, save the result as a BMP.
>
>
> > Is there a bit of an idiots example guide for how to say, put a PNG on
> > the clipboard or a JPG? Some example code? There is a ton of useful
> > info in the pywin32 repo, but I haven't found anything that has made
> > this click for me.
>
> There is no idiots guide, because it cannot be done.  Well, technically
> speaking you can put arbitrary binary data into the clipboard, but other
> graphics applications will not be able to read it.  When they look for
> image data, they look for format CF_DIB, and that means a .BMP.
>
> --
> Tim Roberts, t...@probo.com
> Providenza & Boekelheide, Inc.
>
>
> _______________________________________________
> python-win32 mailing list
> python-win32@python.org
> https://mail.python.org/mailman/listinfo/python-win32
>
_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to