View Full Version : ImageWriter problem
gwendolien
14th July 2016, 21:09
I'm trying to pad and or resize all pictures in a certain folder.
Trying to write the results of a suitable avisynth script I get no output of the ImageWriter at all..
Pic=ImageSource("D:\Data\Digital Camera\test\1967 05 06 Ans op haar kamer Sancta Maria.jpg")
Pic_W=Pic.Width
Pic_H=Pic.Height
GScript("""
If(FMod(Pic_H,2) > 0)
{
Pic=Pic.Crop(0, 1, 0, 0)
}
If(FMod(Pic_W,2) > 0)
{
Pic=Pic.Crop(1, 0, 0, 0)
}
""")
Pic_W=Pic.Width
Pic_H=Pic.Height
GScript("""
If(3.0*Pic_W/(4.0*Pic_H) > 1.01 ) #900x628--->900x675
{
factor=3.0*Pic_W/(4.0*Pic_H)
# Height too small adjust to desired 4:3 aspect ratio by adding borders Top, Bottom
Border=(3*Pic_W/4-Pic_H)/2
Pic=Pic.AddBorders(0, Border, 0, Border).Subtitle(String(Pic_W)+"x"+String(Pic_H)+"/"+"Height too small "+String(factor))
}
If (3.0*Pic_W/(4.0*Pic_H) < 0.99 ) #628x900--->1200x900
{
factor=3.0*Pic_W/(4.0*Pic_H)
# Width too small; AddBorders Left, Right
Border=(4*Pic_H/3-Pic_W)/2
Pic=Pic.AddBorders(Border, 0, Border, 0).Subtitle(String(Pic_W)+"x"+String(Pic_H)+"/"+"Width too small "+String(factor))
}
""")
pic=pic.ConvertToRGB24
pic.ImageWriter(file="D:\Data\Digital Camera\test", type="png", start=0, end=1 )
return pic.IsFormat
StainlessS
14th July 2016, 21:23
Perhaps see here:- http://forum.doom9.org/showthread.php?p=1713501&highlight=ImageSplicer#post1713501
raffriff42
14th July 2016, 21:26
http://avisynth.nl/index.php/ImageWriter
Note that frames are not written to the output file until they are actually rendered by this filter.
pic.ImageWriter(file="D:\Data\Digital Camera\test", type="png", start=0, end=1 )
return pic.IsFormat
You must return the output of ImageWriter in order for the filter to be called. (What is IsFormat anyway?)
gwendolien
14th July 2016, 21:49
Thanks for the prompt reactions!
pic.ImageWriter(file="D:\Data\Digital Camera\test", type="png", start=0, end=1 )
return pic.IsFormat
You must return the output of ImageWriter in order for the filter to be called. (What is IsFormat anyway?)
Trying:
return pic.ImageWriter(file="D:\Data\Digital Camera\test", type="png", start=0, end=1 )
does not result in anything written to a file, helas.
IsFormat is an selfwritten function which adds the type and size of the movie in a subtitle(like, "YV12/720x576")
StainlessS
14th July 2016, 21:56
pic.ImageWriter(file="D:\Data\Digital Camera\test", type="png", start=0, end=1 ) # Assigns result to implicit last
return Last.IsFormat
Groucho2004
14th July 2016, 22:06
Your script from the first post works for me, I just removed the last line ("return pic.IsFormat").
How do you run the script? Does the target path exist?
gwendolien
15th July 2016, 08:35
Stainless, RaffRiff42 and Groucho:
I should have gone to bed yesterday evening instead:
there wasn't any ImageWriter problem, except that I kept looking in the wrong folder.
I wrote the file as:
"D:\Data\Digital Camera\Test"
whereas I constantly looked(and should have written):
"D:\Data\Digital Camera\Test\Test"
which properly resulted in the file "Test000000.png" in the directory where I was looking all the time.
I'm getting too old I'm afraid for this altogether.
My apologies.
raffriff42
15th July 2016, 14:07
IsFormat is an selfwritten function which adds the type and size of the movie in a subtitle(like, "YV12/720x576")Hope you understand if I assumed that IsFormat returned a Boolean. Perhaps it should be called ShowFormat or FormatInfo :p
Groucho2004
15th July 2016, 14:22
Hope you understand if I assumed that IsFormat returned a Boolean. Perhaps it should be called ShowFormat or FormatInfo :p
I also assumed a boolean return value. This is the function he's talking about:
Function IsFormat(clip c)
{
text=IsYV12(c)?"YV12":ISYUY2(c)?"YUY2":IsRGB24(c)?"RGB24":IsRGB32(c)?"RGB32":"other"
return Subtitle(c, text+"\n"+String(c.Width)+"x"+String(c.Height), size=13, y=c.height-26, lsp=0)
}
So, "ShowFormat()" would indeed be more appropriate.
gwendolien
15th July 2016, 21:16
I must apologize for choosing the wrong name and wil correct this here right now.
THANKS for pointing out.
In the mean time, I'm encoutering a real problem with ImageWriter:
the output filename seems to be automatically addded by the enumeration "000000" "000001" etc.
Is there a way to avoid this while writing the picture to disk?
raffriff42
15th July 2016, 22:15
the output filename seems to be automatically added by the enumeration "000000" "000001" etc.
Is there a way to avoid this while writing the picture to disk?
Not sure what you're looking for. You can do this:imgpath="E:\<path>\"
## output like "000000.png", "000001.png"
return ImageWriter(imgpath, type="png")
## output like "file-000000.png", "file-000001.png"
return ImageWriter(imgpath + "file-", type="png")
## output like "file-00.png", "file-01.png"
return ImageWriter(imgpath + "file-%02d.png", type="png")
Groucho2004
15th July 2016, 22:49
In the mean time, I'm encoutering a real problem with ImageWriter:
the output filename seems to be automatically addded by the enumeration "000000" "000001" etc.
Is there a way to avoid this while writing the picture to disk?
There is some good documentation (http://avisynth.nl/index.php/ImageWriter) available.
gwendolien
15th July 2016, 23:15
Thanks RaffRiff42 and Groucho2004.
The documentation pointed at will require a thorough study I'm afraid.
Using the examples of raffriff42 I still can't completely eliminate the zero's:
there is always atleast 1 zero in my output when using %00d
So, how do I completely eliminate the zero's in the output?
raffriff42
16th July 2016, 00:06
"file-%0d.png" will generate numbers with no leading zeros - "file-0.png", "file-1.png" etc.
gwendolien
16th July 2016, 09:47
But what I'm looking for is simply ONLY the string, NO character "0" or "1" at all...
StainlessS
16th July 2016, 10:08
ImageWriter("Test%.0d.jpg",0,0,"jpg")
gwendolien
16th July 2016, 10:28
pic.ImageWriter(pathplusfname+"%.0d.png", 0, 0, "png")
That did it!!
T H A N K S !
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.