Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

Domains: forum.doom9.org / forum.doom9.net / forum.doom9.se

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 14th July 2016, 21:09   #1  |  Link
gwendolien
Registered User
 
Join Date: Nov 2005
Posts: 70
ImageWriter problem

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..
Code:
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
__________________
There is nothing in such perfect harmony with itself as a "contradictio in terminis"
gwendolien is offline   Reply With Quote
Old 14th July 2016, 21:23   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,411
Perhaps see here:- http://forum.doom9.org/showthread.ph...er#post1713501
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 14th July 2016, 21:26   #3  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,371
Quote:
http://avisynth.nl/index.php/ImageWriter
Note that frames are not written to the output file until they are actually rendered by this filter.
Code:
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?)
raffriff42 is offline   Reply With Quote
Old 14th July 2016, 21:49   #4  |  Link
gwendolien
Registered User
 
Join Date: Nov 2005
Posts: 70
Thanks for the prompt reactions!

Quote:
Originally Posted by raffriff42 View Post
Code:
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:
Code:
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")
__________________
There is nothing in such perfect harmony with itself as a "contradictio in terminis"
gwendolien is offline   Reply With Quote
Old 14th July 2016, 21:56   #5  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,411
Code:
pic.ImageWriter(file="D:\Data\Digital Camera\test", type="png", start=0, end=1 )  # Assigns result to implicit last
return Last.IsFormat
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 14th July 2016, 22:06   #6  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
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?
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 15th July 2016, 08:35   #7  |  Link
gwendolien
Registered User
 
Join Date: Nov 2005
Posts: 70
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.
__________________
There is nothing in such perfect harmony with itself as a "contradictio in terminis"
gwendolien is offline   Reply With Quote
Old 15th July 2016, 14:07   #8  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,371
Quote:
Originally Posted by gwendolien View Post
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
raffriff42 is offline   Reply With Quote
Old 15th July 2016, 14:22   #9  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by raffriff42 View Post
Hope you understand if I assumed that IsFormat returned a Boolean. Perhaps it should be called ShowFormat or FormatInfo
I also assumed a boolean return value. This is the function he's talking about:
Code:
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.
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 15th July 2016, 21:16   #10  |  Link
gwendolien
Registered User
 
Join Date: Nov 2005
Posts: 70
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?
__________________
There is nothing in such perfect harmony with itself as a "contradictio in terminis"

Last edited by gwendolien; 15th July 2016 at 21:32. Reason: forgat to mention some aspect
gwendolien is offline   Reply With Quote
Old 15th July 2016, 22:15   #11  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,371
Quote:
Originally Posted by gwendolien View Post
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:
Code:
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")
raffriff42 is offline   Reply With Quote
Old 15th July 2016, 22:49   #12  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by gwendolien View Post
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 available.
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 15th July 2016, 23:15   #13  |  Link
gwendolien
Registered User
 
Join Date: Nov 2005
Posts: 70
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?
__________________
There is nothing in such perfect harmony with itself as a "contradictio in terminis"

Last edited by gwendolien; 15th July 2016 at 23:27.
gwendolien is offline   Reply With Quote
Old 16th July 2016, 00:06   #14  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,371
"file-%0d.png" will generate numbers with no leading zeros - "file-0.png", "file-1.png" etc.
raffriff42 is offline   Reply With Quote
Old 16th July 2016, 09:47   #15  |  Link
gwendolien
Registered User
 
Join Date: Nov 2005
Posts: 70
But what I'm looking for is simply ONLY the string, NO character "0" or "1" at all...
__________________
There is nothing in such perfect harmony with itself as a "contradictio in terminis"
gwendolien is offline   Reply With Quote
Old 16th July 2016, 10:08   #16  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,411
Code:
ImageWriter("Test%.0d.jpg",0,0,"jpg")
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 16th July 2016, 10:28   #17  |  Link
gwendolien
Registered User
 
Join Date: Nov 2005
Posts: 70
pic.ImageWriter(pathplusfname+"%.0d.png", 0, 0, "png")

That did it!!

T H A N K S !
__________________
There is nothing in such perfect harmony with itself as a "contradictio in terminis"
gwendolien is offline   Reply With Quote
Reply

Tags
imagewriter, outputfile

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 23:59.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.