View Full Version : Load image from Windows clipboard
JohannesL
16th June 2009, 19:58
I want to press print screen, and load the image into Avisynth directly.
Is there a way?
Guest
16th June 2009, 20:10
What do you mean by "load the image into Avisynth directly"?
kemuri-_9
16th June 2009, 20:23
guessing he means to be able to automatically generate a 1 frame video clip from the picture data loaded in the clipboard...
and to which my knowledge of avisynth features, the answer is 'no'
shoopdabloop
16th June 2009, 21:21
paste in paint, save as bmp
ImageSource("xxxxxxx.bmp")
Wilbert
16th June 2009, 22:09
It should be possible somehow. This example is done in C# (which i know nothing about): http://www.csharphelp.com/archives3/archive551.html So, at least you can make a plugin which converts the clipboard to a picture. Perhaps it's possible to access the data in AviSynth too??
Any takers before i will try it next week?
some other links which could be useful:
http://www.switchonthecode.com/tutorials/wpf-tutorial-using-the-clipboard
http://msdn.microsoft.com/en-us/library/ms752053.aspx
Guest
16th June 2009, 22:10
I want the OP to clarify the problem.
JohannesL
17th June 2009, 11:53
guessing he means to be able to automatically generate a 1 frame video clip from the picture data loaded in the clipboard...
That's what I want.
hanfrunz
17th June 2009, 13:37
It should be easy to code a input plugin, that does that, but i'm curios for what reason do you want it? You can use tools like xnview/paint/photoshop to paste the clipboard and see the picture...
JohannesL
17th June 2009, 13:53
Convenience, since I will be doing this a lot.
Guest
17th June 2009, 14:19
What are you going to do with one-frame videos?
JohannesL
17th June 2009, 14:39
Apply Avisynth processing and use ImageWriter.
stickboy
18th June 2009, 08:39
If you're going to be doing this a lot, it seems like it'd more practical to save all your screenshots to files first (there are plenty of tools that will save to automatically numbered files) and the use ImageReader on the whole bunch of them.
martin53
28th September 2009, 20:50
Convenience, since I will be doing this a lot.
JohannesL,
I like to do photo processing with Avisynth. Putting the concerned images into a series and use imageReader() is impractical since that would say I need to open all photos with the Avisynth GUI (I use AvsP).
But I prefer to do most of the handling - like scanning through them, cut or do simple corrections - inside a program like XnView. This is much faster and tailored to the dimensions, colorspace, EXIF-handling ... of digital photographs in contrast to movies.
Still, some of the photos require correction with filters that I only can find for Avisynth.
I wrote a .VBS script for that purpose these days. Maybe you like it too.
Prerequisites
- of course, use Windows
- install an .AVS editor like AvsP and assign the extension .avs to it.
- install ImageMagick including the COM+ Object
How To Use the Script
To use it, drop a graphics file onto the script or a link to the script. In XnView, you can assign an Alt+number keyboard shortcut to it.
Alternatively, copy an image to the clipboard and open the .VBS without a command line parameter.
The .VBS script generates a tailored but generic .AVS script and opens it.
Either the file that you gave to the .VBS script is used inside the ImageReader() command, or the .VBS script saved the clipboard with the help of ImageMagick to a temporal file and opens this temporal file.
While you work with AvsP, the .VBS script waits in background.
The .AVS script should contain the ImageWriter() command with the temporal name.
When you close AvsP, the .VBS script puts this file into the clipboard with the help of ImageMagick again.
Your workflow is (assuming you use XnView and have the sript on Alt+1):
1. Have any image open
2. press Alt+1
3. the generic .AVS sript opens
4. modify the .AVS script in AvsP by removing comments, changing parameters etc. but switch the preview on and accept that the .AVS script will be somewhat slow since it ImageWriter()'s all of your steps
5. close AvsP
6. press Ctrl+V
==> Now your original image is overwritten with the content that you processed inside AvsP. But the EXIF and IPTC data etc persist!
''''''''''''''''''''''''''
' declarations:
''''''''''''''''''''''''''
Const myTemp= "C:\temp\"
''''''''''''''''''''''''''
' functions:
''''''''''''''''''''''''''
function writeAVS(sourceline)
set oFS = CreateObject("Scripting.FileSystemObject")
set f = oFS.CreateTextFile(myTemp & "AvsP.avs", true)
f.WriteLine(replace(sourceline, "'", chr(34)))
f.WriteLine(replace("a=last", "'", chr(34)))
f.WriteLine(replace("LanczosResize(a.width()-a.width()%4,a.height()-a.height()%4)", "'", chr(34)))
f.WriteLine(replace("#ConvertToYV12().hdr(0.5)", "'", chr(34)))
f.WriteLine(replace("ConvertToRGB32()", "'", chr(34)))
f.WriteLine(replace("LanczosResize(a.width(),a.height())", "'", chr(34)))
f.WriteLine(replace("MergeARGB(a, last, last, last)", "'", chr(34)))
f.WriteLine(replace("ImageWriter('f:\temp\AvsP', Type='tif')", "'", chr(34)))
f.close
set oFS= nothing
end function
''''''''''''''''''''''''''
' Start of script:
''''''''''''''''''''''''''
set oSH = WScript.CreateObject("WScript.Shell")
set oIM= CreateObject("ImageMagickObject.MagickImage.1")
set args = Wscript.Arguments
if args.Count > 0 then
for i = 0 to args.count -1
arg=args(i)
writeAVS("ImageSource('" & arg & "',0,0,25,pixel_type='rgb32')")
oSH.Run myTemp & "AvsP.avs", 5, true
msgs = oIM.Convert(myTemp & "AvsP000000.tif", "clipboard:")
next
else
msgs = oIM.Convert("clipboard:", myTemp & "AvsP.tif")
writeAVS("ImageSource('" & myTemp & "'AvsP.tif',0,0,25,pixel_type='rgb32')")
oSH.Run myTemp & "AvsP.avs", 5, true
msgs = oIM.Convert(myTemp & "AvsP000000.tif", "clipboard:")
end if
... extend the writeAVS() function to what you usually need inside this kind of .AVS script and ...
enjoy
martin53
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.