单页批量多图像打印 [英] BATCH Multiple Image Printing on Single Sheet
问题描述
我有一个图像文件夹及放于1000年;我想调整和放大器;打印每sheet.Using批处理脚本,收集从文件夹和输出3 colums&放一个HTML脚本,图片12至24幅图像;每页6行,在Firefox中打开(缩小以适合&安培;打印)。
如何每张图片上的HTML脚本添加文件名,日期。
块引用>删除C:\\ zz.html
SETLOCAL EnableDelayedExpansion
集/一个P = 1
集/一个M = 2
设定/一个W = 4
回声^<表CELLSPACING =10的风格=边界:1px的纯黑色,^> >>C:\\ zz.html
FOR / Fdelims =%% i的('DIR / S / B / A-D F:\\ JPEG \\ MDL \\ *。JPG)做(
集/一个P = + 1
呼应P!!
如果P!! == M!! (
集博=)
如果P!! ==!W¯¯! (
设定为p = 1
设置博=< TR>中)
!呼应博^< TD ^> ^< IMG WIDTH = 320 HEIGHT = 260 SRC =文件:\\\\ %%我^> >>C:\\ zz.html
)
启动C:\\ Program Files文件\\ Mozilla Firefox的\\ firefox.exeC:\\ zz.html&放大器;退出下面是可用的code
删除C:\\ zz.html
SETLOCAL EnableDelayedExpansion
集/一个P = 1
集/一个M = 2
设定/一个W = 4
回声^<表CELLSPACING =10的风格=边界:1px的纯黑色,^> >>C:\\ zz.html
FOR / Fdelims =%% i的('DIR / S / B / A-D%1 \\ *。*')做(
回音1%
集/一个P = + 1
呼应P!!
如果P!! == M!! (
集博=)
如果P!! ==!W¯¯! (
设定为p = 1
设置博=< TR>中)
!呼应博^< TD ^> ^< IMG WIDTH = 320 HEIGHT = 260 SRC =文件:\\\\ %%我^> ^< BR ^> %%〜NXI>> C:\\ zz.html
)
启动I:\\ HEVC \\ M-盎司\\ m.f -no远程-profileI:\\ HEVC \\ M-ozyC:\\ zz.html&放大器;退出此的注册表项提供了右键点击打印任何文件夹中。 (您可以随时更改源文件夹)
Windows注册表编辑器5.00版[HKEY_CLASSES_ROOT \\目录\\壳\\ == ==果酱J]。
@ =打印=== ALL = IN = 1 ==[HKEY_CLASSES_ROOT \\目录\\壳\\ == ==果酱J□\\命令]
@ =我:\\\\ \\\\小号\\\\ PPP_Print p.cmd \\%1 \\
解决方案我承认,你放一点精力来开始你的项目,但你似乎需要很多的帮助。我AP preciate你thusfar分享你的进步。我想这会让你值得圣诞节present的。 :)
您的问题有几个组成部分的问题,我看到的。
1。我想调整和放大器;每张纸上打印12到24个图像。的
块引用>选择一个。你要12或24?如果您要根据您要打印图像的高度数是可变的,你可能会更好调查ImageMagick的如上建议。
的 2。使用批处理脚本来收集从文件夹和输出3 colums&放一个HTML脚本图像;每页6行的
块引用>3 * 6 = 18,让我们这一点。 8.5X11页面会处理有点过高度900px,所以你的表格单元格的高度设置为150像素。 (150 * 6 = 900)。
的 3。在Firefox打开(缩小以适合&安培;打印)的
块引用>您可以通过包括一些JavaScript调用触发打印对话框
window.print();
。你还是要点击打印。
4。如何添加HTML上的每一个剧本图像上的文件名,日期。的
块引用>假设
%%我
是分配给捕获的文件名中的为
循环变量。要获得basename.ext
的文件,使用%%〜NXI
。要获得文件的最后修改日期和时间,使用%%〜TI
。请参阅在控制台窗口中的帮助最后两页
有关此语法的更多信息。使用CSS
的位置是:绝对
上的文字都和你的图像和的位置是:相对
的D
含有这些元素。如果不是这样,或者你可以加载图片作为背景图片,只是显示在顶部的文本内联。这需要你的Firefox配置为打印背景图片,这可能不是进行配置,虽然。要放18张图像在页面上,依次通过你的形象在一次文件18,那么一旦18图像中生成一个HTML表。在你的CSS添加
@media打印
声明,以保证打印时,每个表触发分页符。要生成HTML,我认为它会成为你的codeA一点更具可读性,更容易维护,聘请一批定界符功能。圣诞快乐!
关闭@echo
SETLOCAL enabledelayedexpansion
:: thumbnails.bat
::生成当前文件夹中的* .JPG的打印布局
:: http://stackoverflow.com/a/27652107/1683264集HTMLFILE = out.html致电:定界符头>中%HTMLFILE%&放大器;&安培;转到END_HEAD
<!^ DOCTYPEHTML>
< HTML和GT;
< HEAD>
<风格类型=文/ CSS>
一个{文字修饰:无; }
IMG {
最大宽度:200像素;
最大高度:150像素;
位置:绝对的;
左:0像素;
底部:0像素;
}
TD {
边框:1px的纯黑色;
位置:相对;
宽度:200像素;
高度:150像素;
}
跨度 {
位置:绝对的;
左:5像素;
上图:5像素;
颜色:紫色;
FONT-FAMILY:宋体;
字体大小:11像素;
背景:RGBA(255,255,255,0.6);
顶部:的3px;
左:的3px;
}
@media打印{
表{分页符,后:永远; }
}
< /风格>
<脚本类型=文/ JavaScript的>
的addEventListener('负荷',函数(){window.print();},FALSE);
< / SCRIPT>
< /头>
<身体GT;
:END_HEAD集数= 1
图像集=
为%%我在(* .JPG)做(
图像集=!图片! %%〜FI
如果!算! EQU 18(
拨打:build_table图片:〜!1!
图像集=
设置计数= 0
)
设置/计数+ = 1
)如果计数%GTR%1来电:build_table图片:1〜!致电:定界符身体GT;>中%HTMLFILE%&放大器;&安培;转到END_BODY
< /身体GT;
< / HTML>
:END_BODY启动火狐-new选项卡的file:///%CD:\\ = /%/%HTMLFILE%::主要脚本结束
GOTO:EOF:build_table<&IMG1 GT; <&IMG2 GT; ...< img18>
SETLOCAL enabledelayedexpansion
集数= 1
为%%我在(%*)做(
集SRC = %%〜我
设置IMG计数=&下; A HREF =!的文件:///的src:!\\ = />&下; IMG SRC =文件:///的src:!\\ = //>
设置DESC数=<! - 跨度GT; %%〜NXI< BR /> %%〜TI< / SPAN>< / A>中
设置/计数+ = 1
)
致电:定界符表>>中%HTMLFILE%&放大器;&安培;转到END_TABLE
<表CELLSPACING =5>
&所述; TR>
< TD>!IMG1 !! DESC1<!/ TD>
< TD>!IMG2 !! DESC2<!/ TD>
&所述; TD>!IMG3 !! desc3&下;!/ TD>
< / TR>
&所述; TR>
&所述; TD>!IMG4 !! desc4&下;!/ TD>
&所述; TD>!IMG5 !! desc5&下;!/ TD>
&所述; TD>!img6 !! desc6&下;!/ TD>
< / TR>
&所述; TR>
< TD>!IMG7 !! desc7<!/ TD>
&所述; TD>!img8 !! desc8&下;!/ TD>
&所述; TD>!img9 !! desc9&下;!/ TD>
< / TR>
&所述; TR>
< TD>!img10 !! desc10< / TD>
< TD>!img11 !! desc11< / TD>
< TD>!img12 !! desc12< / TD>
< / TR>
&所述; TR>
< TD>!img13 !! desc13< / TD>
< TD>!看好你哦!!! desc14< / TD>
< TD>!img15 !! desc15< / TD>
< / TR>
&所述; TR>
< TD>!img16 !! desc16< / TD>
< TD>!img17 !! desc17< / TD>
< TD>!img18 !! desc18< / TD>
< / TR>
< /表>:茶几
ENDLOCAL
GOTO:EOF:: http://stackoverflow.com/a/15032476/1683264
:定界符< uniqueIDX>
SETLOCAL enabledelayedexpansion
设置去=
FOR / Fdelims =%%的A('FINDSTR / N^%〜F0')做(
一套行= %% A&放大器;&安培;集!行=行:*:!=
如果去定义(如#线:〜!1 ==#去:: =(GOTO:!!!!!EOF)其他回波(行)
如果!行:0,13〜!==称:定界符(
FOR / F令牌= 3 delims => ^(!行)于%%怎么办?(
如果#%%我==#%1(
FOR / F令牌= 2 delims =安培; %%我在(!行!)做(
FOR / F令牌= 2%%倍In(%% I)也将走= %% X
)
)
)
)
)
GOTO:EOFI got 1000's of images on a folder & I wanna resize & print 12 to 24 images per sheet.Using BATCH script to collect images from a folder and output an HTML script with 3 colums & 6 rows per page , open in firefox (shrink to fit &print) .
how to add filename, date on every image on html script.
del "c:\zz.html" setlocal EnableDelayedExpansion set /a "p=1" set /a "m=2" set /a "w=4" echo ^<table cellspacing="5" style="border:1px solid black;"^> >>"c:\zz.html" for /f "delims=" %%i in ('dir /s/b /a-d f:\jpeg\mdl\*.jpg') do ( set /a "p=p+1" echo !p! if !p! == !m! ( set "bo=") if !p! == !w! ( set "p=1" set "bo=<tr>") echo !bo!^<td^>^<img width=320 height=260 src="file:\\%%i"^> >>"c:\zz.html" ) start C:\Program Files\Mozilla Firefox\firefox.exe "c:\zz.html" &exit
Here is the usable code
del "c:\zz.html" setlocal EnableDelayedExpansion set /a "p=1" set /a "m=2" set /a "w=4" echo ^<table cellspacing="5" style="border:1px solid black;"^> >>"c:\zz.html" for /f "delims=" %%i in ( 'dir /s/b /a-d %1\*.*' ) do ( echo %1 set /a "p=p+1" echo !p! if !p! == !m! ( set "bo=") if !p! == !w! ( set "p=1" set "bo=<tr>") echo !bo!^<td^>^<img width=320 height=260 src="file:\\%%i"^>^<br^>%%~nxi >>"c:\zz.html" ) start I:\HEVC\m-oz\m.f -no-remote -profile "I:\HEVC\m-ozy" "c:\zz.html" &exit
This reg key provide Right-Click to print any folder. (change the source folder as you like)
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\shell\==jam==j] @="Print===ALL=IN=1==" [HKEY_CLASSES_ROOT\Directory\shell\==jam==j\Command] @="I:\\s\\PPP_Print\\p.cmd \"%1\""
解决方案I recognize that you put a bit of effort into starting your project, but you appear to need lots of help. I appreciate your sharing your progress thusfar. I guess this makes you worthy of a Christmas present. :)
Your question has several component questions that I see.
1. I wanna resize & print 12 to 24 images per sheet.
Pick one. Do you want 12 or 24? If you want the number to be variable based on the height of the images you're printing, you'd probably be better off investigating Imagemagick as suggested above.
2. Using BATCH script to collect images from a folder and output an HTML script with 3 colums & 6 rows per page
3 * 6 = 18. Let's go with that. An 8.5"x11" page will handle a bit over 900px of height, so set the height of your table cells to 150px. (150 * 6 = 900.)
3. open in firefox (shrink to fit &print)
You can trigger the print dialog by including a bit of JavaScript to call
window.print();
. You still have to click "Print".4. how to add filename, date on every image on html script.
Assume
%%I
is the variable assigned to capture filenames in yourfor
loop. To get thebasename.ext
of a file, use%%~nxI
. To get the file's last modified date and time, use%%~tI
. See the last two pages ofhelp for
in a console window for more information on this syntax.Use CSS
position: absolute
on both your text and your images, andposition: relative
on thetd
elements containing them. Either that, or you can load your images as background images and just display the text inline on top. This requires you to configure Firefox to print background images, which might not be configured, though.To put 18 images on a page, loop through your image files 18 at a time, then generate an HTML table once the 18th image is found. In your CSS add a
@media print
declaration to ensure each table triggers a page break when printed. To generate your HTML, I suggest that it'd make your code a little more readable and easier to maintain, to employ a batch heredoc function.Merry Christmas!
@echo off setlocal enabledelayedexpansion :: thumbnails.bat :: generates print layout of *.jpg in current folder :: http://stackoverflow.com/a/27652107/1683264 set "htmlfile=out.html" call :heredoc head >"%htmlfile%" && goto end_head <^!doctype "html"> <html> <head> <style type="text/css"> a { text-decoration: none; } img { max-width: 200px; max-height: 150px; position: absolute; left: 0px; bottom: 0px; } td { border: 1px solid black; position: relative; width: 200px; height: 150px; } span { position: absolute; left: 5px; top: 5px; color: purple; font-family: "Times New Roman"; font-size: 11px; background: rgba(255, 255, 255, 0.6); top: 3px; left: 3px; } @media print { table { page-break-after: always; } } </style> <script type="text/javascript"> addEventListener('load', function() { window.print(); }, false); </script> </head> <body> :end_head set count=1 set images= for %%I in (*.jpg) do ( set images=!images! "%%~fI" if !count! equ 18 ( call :build_table !images:~1! set images= set count=0 ) set /a count+=1 ) if %count% gtr 1 call :build_table !images:~1! call :heredoc body >>"%htmlfile%" && goto end_body </body> </html> :end_body start "" "firefox" -new-tab "file:///%CD:\=/%/%htmlfile%" :: End of main script goto :EOF :build_table <img1> <img2> ... <img18> setlocal enabledelayedexpansion set count=1 for %%I in (%*) do ( set "src=%%~I" set "img!count!=<a href="file:///!src:\=/!"><img src="file:///!src:\=/!" />" set "desc!count!=<span>%%~nxI<br />%%~tI</span></a>" set /a count+=1 ) call :heredoc table >>"%htmlfile%" && goto end_table <table cellspacing="5"> <tr> <td>!img1!!desc1!</td> <td>!img2!!desc2!</td> <td>!img3!!desc3!</td> </tr> <tr> <td>!img4!!desc4!</td> <td>!img5!!desc5!</td> <td>!img6!!desc6!</td> </tr> <tr> <td>!img7!!desc7!</td> <td>!img8!!desc8!</td> <td>!img9!!desc9!</td> </tr> <tr> <td>!img10!!desc10!</td> <td>!img11!!desc11!</td> <td>!img12!!desc12!</td> </tr> <tr> <td>!img13!!desc13!</td> <td>!img14!!desc14!</td> <td>!img15!!desc15!</td> </tr> <tr> <td>!img16!!desc16!</td> <td>!img17!!desc17!</td> <td>!img18!!desc18!</td> </tr> </table> :end_table endlocal goto :EOF :: http://stackoverflow.com/a/15032476/1683264 :heredoc <uniqueIDX> setlocal enabledelayedexpansion set go= for /f "delims=" %%A in ('findstr /n "^" "%~f0"') do ( set "line=%%A" && set "line=!line:*:=!" if defined go (if #!line:~1!==#!go::=! (goto :EOF) else echo(!line!) if "!line:~0,13!"=="call :heredoc" ( for /f "tokens=3 delims=>^ " %%i in ("!line!") do ( if #%%i==#%1 ( for /f "tokens=2 delims=&" %%I in ("!line!") do ( for /f "tokens=2" %%x in ("%%I") do set "go=%%x" ) ) ) ) ) goto :EOF
这篇关于单页批量多图像打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!