[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

如何把多张jpg拼合成一张jpg长图(20元)

例如:文件夹1--
                     图1.jpg
                     图2.jpg
                     图3.jpg
                     图4.jpg
结果:文件夹1--
                     图1.jpg

回复 1# bao9688
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. REM 处理该文件夹下的图片
  4. set "SrcFolder=D:\Test\Picture"
  5. REM 根据自己电脑实际情况设置ImageMagick的路径
  6. set "path=C:\Program Files\ImageMagick;%path%"
  7. if not exist "%SrcFolder%" (
  8.     echo 找不到待处理的图片文件夹
  9.     pause
  10.     goto :eof
  11. )
  12. cd /d "%SrcFolder%"
  13. set "n=0"
  14. for /f "delims=" %%j in ('dir /b /a-d "*.jpg"') do (
  15.     set /a n+=1
  16. )
  17. echo 正在处理文件夹:%SrcFolder% [包含!n!个jpg图片]
  18. montage.exe "*.jpg" -tile 1x!n! -geometry +10+10 "%temp%\拼接.jpg"
  19. del /f /q *.jpg
  20. move /y "%temp%\拼接.jpg" .
  21. pause
复制代码
ImageMagick官方下载地址:
https://imagemagick.org/script/download.php#windows
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

回复 1# bao9688


http://bbs.bathome.net/thread-61893-1-1.html
这个帖子也是你的吗?
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

我在国外找到一个系统相关的图像处理函数, 可以不用第三方组件, 感觉应该也可以实现, 编程水平有限, 期待高手能试试改一下
  1. function Get-Image {
  2.     <#
  3.     .Synopsis
  4.         Gets information about images.
  5.     .Description
  6.         Get-Image gets an object that represents each image file.
  7.         The object has many properties and methods that you can use to edit images in Windows PowerShell.
  8.     .Notes
  9.         Get-Image uses Wia.ImageFile, a Windows Image Acquisition COM object to get image data.
  10.         Then it uses the Add-Member cmdlet to add note properties and script methods to the object.
  11.         The Resize script method uses the Add-ScaleFilter function. It has the following syntax:
  12.         Resize ($width, $height, [switch]$DoNotPreserveAspectRation).
  13.         Width and Height can be specified in pixels or percentages.
  14.         For a description of these parameters, type "get-help Add-ScaleFilter –par *".
  15.         The Crop script method uses the uses the Add-CropFilter function. It has the following syntax:
  16.         Crop ([Double]$left, [Double]$top, [Double]$right, [Double]$bottom).
  17.         All dimensions are measured in pixels.
  18.         For a description of these parameters, type "get-help Add-CropFilter –par *".
  19.         The FlipVertical, FlipHorizontal, RotateClockwise and RotateCounterClockwise script methods use the Add-RotateFlipFilter function.
  20.         For a description of these parameters, type "get-help Add-RotateFlipFilter –par *".
  21.     .Parameter File
  22.         [Required] Specifies the image files. Enter the path and file name of an image file, such as $home\pictures\MyPhoto.jpg.
  23.         You can also pipe one or more image files to Get-Image, such as those from Get-Item or Get-Childitem (dir).
  24.     .Example
  25.         Get-Image –file C:\myPics\MyPhoto.jpg
  26.     .Example
  27.         Get-ChildItem $home\Pictures -Recurse | Get-Image        
  28.     .Example
  29.         (Get-Image –file C:\myPics\MyPhoto.jpg).resize(80, 120)
  30.     .Example
  31.         # Crops 8 pixels from the top of the image.
  32.         $CatPhoto = Get-Image –file $home\Pictures\Cat.jpg
  33.         $CatPhoto.crop(0,8,0,0)
  34.     .Example
  35.         $CatPhoto = Get-Image –file $home\Pictures\Cat.jpg
  36.         $CatPhoto.flipvertical()
  37.     .Example
  38.         dir $home\pictures\Vacation*.jpg | get-image | format-table fullname, horizontalResolution, PixelDepth –autosize
  39.     .Link
  40.         "Image Manipulation in PowerShell": http://blogs.msdn.com/powershell/archive/2009/03/31/image-manipulation-in-powershell.aspx
  41.     .Link
  42.         Add-CropFilter
  43.     .Link
  44.         Add-ScaleFilter
  45.     .Link
  46.         Add-RotateFlipFilter
  47.     .Link
  48.         Get-ImageProperties
  49.     #>
  50.     param(   
  51.     [Parameter(ValueFromPipelineByPropertyName=$true,Mandatory=$true)]
  52.     [Alias('FullName')]
  53.     [string]$file)
  54.    
  55.     process {
  56.         $realItem = Get-Item $file -ErrorAction SilentlyContinue     
  57.         if (-not $realItem) { return }
  58.         $image  = New-Object -ComObject Wia.ImageFile        
  59.         try {        
  60.             $image.LoadFile($realItem.FullName)
  61.             $image |
  62.                 Add-Member NoteProperty FullName $realItem.FullName -PassThru |
  63.                 Add-Member ScriptMethod Resize {
  64.                     param($width, $height, [switch]$DoNotPreserveAspectRatio)                    
  65.                     $image = New-Object -ComObject Wia.ImageFile
  66.                     $image.LoadFile($this.FullName)
  67.                     $filter = Add-ScaleFilter @psBoundParameters -passThru -image $image
  68.                     $image = $image | Set-ImageFilter -filter $filter -passThru
  69.                     Remove-Item $this.Fullname
  70.                     $image.SaveFile($this.FullName)                    
  71.                 } -PassThru |
  72.                 Add-Member ScriptMethod Crop {
  73.                     param([Double]$left, [Double]$top, [Double]$right, [Double]$bottom)
  74.                     $image = New-Object -ComObject Wia.ImageFile
  75.                     $image.LoadFile($this.FullName)
  76.                     $filter = Add-CropFilter @psBoundParameters -passThru -image $image
  77.                     $image = $image | Set-ImageFilter -filter $filter -passThru
  78.                     Remove-Item $this.Fullname
  79.                     $image.SaveFile($this.FullName)                    
  80.                 } -PassThru |
  81.                 Add-Member ScriptMethod FlipVertical {
  82.                     $image = New-Object -ComObject Wia.ImageFile
  83.                     $image.LoadFile($this.FullName)
  84.                     $filter = Add-RotateFlipFilter -flipVertical -passThru
  85.                     $image = $image | Set-ImageFilter -filter $filter -passThru
  86.                     Remove-Item $this.Fullname
  87.                     $image.SaveFile($this.FullName)                    
  88.                 } -PassThru |
  89.                 Add-Member ScriptMethod FlipHorizontal {
  90.                     $image = New-Object -ComObject Wia.ImageFile
  91.                     $image.LoadFile($this.FullName)
  92.                     $filter = Add-RotateFlipFilter -flipHorizontal -passThru
  93.                     $image = $image | Set-ImageFilter -filter $filter -passThru
  94.                     Remove-Item $this.Fullname
  95.                     $image.SaveFile($this.FullName)                    
  96.                 } -PassThru |
  97.                 Add-Member ScriptMethod RotateClockwise {
  98.                     $image = New-Object -ComObject Wia.ImageFile
  99.                     $image.LoadFile($this.FullName)
  100.                     $filter = Add-RotateFlipFilter -angle 90 -passThru
  101.                     $image = $image | Set-ImageFilter -filter $filter -passThru
  102.                     Remove-Item $this.Fullname
  103.                     $image.SaveFile($this.FullName)                    
  104.                 } -PassThru |
  105.                 Add-Member ScriptMethod RotateCounterClockwise {
  106.                     $image = New-Object -ComObject Wia.ImageFile
  107.                     $image.LoadFile($this.FullName)
  108.                     $filter = Add-RotateFlipFilter -angle 270 -passThru
  109.                     $image = $image | Set-ImageFilter -filter $filter -passThru
  110.                     Remove-Item $this.Fullname
  111.                     $image.SaveFile($this.FullName)                    
  112.                 } -PassThru
  113.                
  114.         } catch {
  115.             Write-Verbose $_
  116.         }
  117.     }   
  118. }  
复制代码

TOP

  1. #requires -version 2.0
  2. function Add-CropFilter {   
  3.     <#
  4.     .Synopsis
  5.     Creates a filter for cropping images.
  6.     .Description
  7.     The Add-CropFilter function adds a Crop image filter to a filter collection.
  8.     It creates a new filter collection if none exists. An image filter is Windows Image Acquisition (WIA) concept.
  9.     Each filter represents a change to an image.
  10.     Add-CropFilter does not crop images; it just creates a crop filter.
  11.     To crop an image, use the Crop method of the Get-Image function, which uses a crop filter that Add-CropFilter creates,
  12.     or the Set-ImageFilter function, which applies the filters.
  13.     All of the parameters of this function are optional.
  14.     Without parameters, Add-CropFilter creates an image filter collection.
  15.     Then it creates a crop filter that is not specific to an image and will not crop image content (values for the Left, Top, Right, and Bottom parameters are 0).
  16.     .Parameter Filter
  17.         Enter a filter collection (Wia.ImageProcess COM object).
  18.         Each filter in the collection represents a unit of modification to a WiA ImageFile object.
  19.         This parameter is optional. If you do not submit a filter collection, Add-CropFilter creates one for you.
  20.     .Parameter Image
  21.         Creates a crop filter for the specified image.
  22.         Enter an image object, such as one returned by the Get-Image function.
  23.         This parameter is optional.
  24.         If you do not specify an image, Add-CropFilter creates a crop filter that is not image-specific.
  25.         If you do not specify an image, you cannot specify percentage values (values less than 1) for the
  26.         Left, Top, Right, or Bottom parameters.
  27.     .Parameter Left
  28.         Specifies the how much to crop from the left side of the image.
  29.         The default value is zero (0). To specify pixels, enter a value greater than one (1).
  30.         To specify a percentage, enter a value less than one (1), such as ".25".
  31.         Percentages are valid only when the command includes the Image parameter.
  32.     .Parameter Top
  33.         Specifies the how much to crop from the top of the image.
  34.         The default value is zero (0). To specify pixels, enter a value greater than one (1).
  35.         To specify a percentage, enter a value less than one (1), such as ".25".
  36.         Percentages are valid only when the command includes the Image parameter.
  37.     .Parameter Right
  38.         Specifies the how much to crop from the right side of the image.
  39.         The default value is zero (0).
  40.         To specify pixels, enter a value greater than one (1).
  41.         To specify a percentage, enter a value less than one (1), such as ".25".
  42.         Percentages are valid only when the command includes the Image parameter.
  43.     .Parameter Bottom
  44.         Specifies the how much to crop from the bottom of the image.
  45.         The default value is zero (0).
  46.         To specify pixels, enter a value greater than one (1).
  47.         To specify a percentage, enter a value less than one (1), such as ".25".
  48.         Percentages are valid only when the command includes the Image parameter.
  49.     .Parameter Passthru
  50.         Returns an object that represents the crop filter.
  51.         By default, this function does not generate output.
  52.     .Notes
  53.         Add-CropFilter uses the Wia.ImageProcess object.
  54.     .Example
  55.         Add-CropFilter –right 45 –bottom 22 –passthru
  56.     .Example
  57.         $i = get-image .\Photo01.jpg
  58.         Add-CropFilter –image $i –top .3 -passthru
  59.     .Example
  60.         C:\PS> $cf = Add-CropFilter –passthru
  61.         C:\PS> ($cf.filters | select properties).properties | format-table Name, Value –auto
  62.         Name       Value
  63.         ----       -----
  64.         Left           0
  65.         Top            0
  66.         Right         45
  67.         Bottom        22
  68.         FrameIndex     0
  69.     .Example
  70.         $image = Get-Image .\Photo01.jpg            
  71.         $image = $image | Set-ImageFilter -filter (Add-CropFilter -Image $image -Left .1 -Right .1 -Top .1 -Bottom .1 -passThru) -passThru                    
  72.         $image.SaveFile(".\Photo02.jpg")
  73.     .Link
  74.         Get-Image
  75.     .Link
  76.         Set-ImageFilter
  77.     .Link
  78.         Image Manipulation in PowerShell:
  79.         http://blogs.msdn.com/powershell/archive/2009/03/31/image-manipulation-in-powershell.aspx
  80.     .Link
  81.         "ImageProcess object" in MSDN
  82.         http://msdn.microsoft.com/en-us/library/ms630507(VS.85).aspx
  83.     .Link
  84.         "Filter Object" in MSDN
  85.         http://msdn.microsoft.com/en-us/library/ms630501(VS.85).aspx
  86.     .Link
  87.         "How to Use Filters" in MSDN
  88.         http://msdn.microsoft.com/en-us/library/ms630819(VS.85).aspx
  89.     #>
  90.     param(
  91.     [Parameter(ValueFromPipeline=$true)]
  92.     [__ComObject]
  93.     $filter,
  94.    
  95.     [__ComObject]
  96.     $image,
  97.         
  98.     [Double]$left,
  99.     [Double]$top,
  100.     [Double]$right,
  101.     [Double]$bottom,
  102.    
  103.     [switch]$passThru                     
  104.     )
  105.    
  106.     process {
  107.         if (-not $filter) {
  108.             $filter = New-Object -ComObject Wia.ImageProcess
  109.         }
  110.         $index = $filter.Filters.Count + 1
  111.         if (-not $filter.Apply) { return }
  112.         $crop = $filter.FilterInfos.Item("Crop").FilterId                    
  113.         $isPercent = $true
  114.         if ($left -gt 1) { $isPercent = $false }
  115.         if ($top -gt 1) { $isPercent = $false }
  116.         if ($right -gt 1) { $isPercent = $false }
  117.         if ($bottom -gt 1) { $isPercent = $false }
  118.         $filter.Filters.Add($crop)
  119.         if ($isPercent -and $image) {
  120.             $filter.Filters.Item($index).Properties.Item("Left") = $image.Width * $left
  121.             $filter.Filters.Item($index).Properties.Item("Top") = $image.Height * $top
  122.             $filter.Filters.Item($index).Properties.Item("Right") = $image.Width * $right
  123.             $filter.Filters.Item($index).Properties.Item("Bottom") = $image.Height * $bottom
  124.         } else {
  125.             $filter.Filters.Item($index).Properties.Item("Left") = $left
  126.             $filter.Filters.Item($index).Properties.Item("Top") = $top
  127.             $filter.Filters.Item($index).Properties.Item("Right") = $right
  128.             $filter.Filters.Item($index).Properties.Item("Bottom") = $bottom                    
  129.         }
  130.         if ($passthru) { return $filter }         
  131.     }
  132. }
复制代码

TOP

  1. #requires -version 2.0
  2. function Add-OverlayFilter {   
  3.     <#
  4.     .Synopsis
  5.     Creates a filter for overlaying images.
  6.     .Description
  7.     The Add-OverlayFilter function adds a Stamp filter of an image to a filter collection.
  8.     The stamp filter lets you layer the specified image over another images.
  9.     Add-OverlayFilter creates a new filter collection if none exists.
  10.     An image filter is Windows Image Acquisition (WIA) concept.
  11.     Each filter represents a change to an image.
  12.     Add-OverlayFilter does not overlay images; it only creates a filter.
  13.     To overlay the image use the Set-ImageFilter function, which applies the filters.
  14.     The Image parameter of Add-OverlayFilter is required. You cannot create a stamp (overlay) filter that is not specific to an image.
  15.     .Parameter Image
  16.     Mandatory. Creates a stamp filter of the specified image.
  17.     This parameter is required. Enter an image object, such as one returned by the Get-Image function.
  18.     The image that is used in the filter is placed over other images when you apply the filter.
  19.     .Parameter Filter
  20.     Enter a filter collection (a Wia.ImageProcess COM object).
  21.     You can also pipe a filter collection to Add-OverlayFilter.
  22.     Each filter in the collection represents one change to an image.
  23.     This parameter is optional. If you do not submit a filter collection, Add-OverlayFilter creates one for you.
  24.     .Parameter Left
  25.     The horizontal location within the image where the overlay is added.
  26.     The default value is zero (0). Enter a value in pixels from the left edge of the image.
  27.     .Parameter Top
  28.     The vertical location within the image where the overlay is added.
  29.     The default value is zero (0). Enter a value in pixels from the top edge of the image.
  30.     .Parameter Passthru
  31.     Returns an object that represents the stamp filter.
  32.     By default, this function does not generate output.
  33.     .Notes
  34.     Add-OverlayFilter uses the Wia.ImageProcess object.
  35.     .Example
  36.     Add-OverlayFilter –image (get-image .\Colors.jpg) –left 10 –top 10 –passthru
  37.     .Example
  38.     $i = get-image .\Colors.jpg
  39.     $ol = Add-OverlayFilter –image $i –top 42 –passthru
  40.     .Example
  41.     C:\PS> $i = get-image .\Colors.jpg
  42.     C:\PS> $of = Add-OverlayFilter –image $i –top 20 –left 20 –passthru
  43.     C:\PS> ($of.filters | select properties).properties |  format-table –property Name, Value –auto
  44.     Name       Value         
  45.     ----       -----         
  46.     ImageFile  System.__ComObject
  47.     Left       20
  48.     Top        20
  49.     FrameIndex 0     
  50.     .Example
  51.     $layer = Get-Image .\Prism.jpg
  52.     $photo = Get-Image .\Photo01.jpg            
  53.     $NewImage = $photo | Set-ImageFilter -filter (Add-OverLayFilter -Image $layer -Left 10 -Top 10 -passThru) -passThru                    
  54.     $NewImage.SaveFile(".\Photo01_Edited.jpg")
  55.     .Link
  56.     Get-Image
  57.     .Link
  58.     Set-ImageFilter
  59.     .Link
  60.     Image Manipulation in PowerShell:
  61.     http://blogs.msdn.com/powershell/archive/2009/03/31/image-manipulation-in-powershell.aspx
  62.     .Link
  63.     "ImageProcess object" in MSDN
  64.     http://msdn.microsoft.com/en-us/library/ms630507(VS.85).aspx
  65.     .Link
  66.     "Filter Object" in MSDN
  67.     http://msdn.microsoft.com/en-us/library/ms630501(VS.85).aspx
  68.     .Link
  69.     "How to Use Filters" in MSDN
  70.     http://msdn.microsoft.com/en-us/library/ms630819(VS.85).aspx
  71.     #>
  72.     param(
  73.     [Parameter(ValueFromPipeline=$true)]
  74.     [__ComObject]
  75.     $filter,
  76.    
  77.     [__ComObject]
  78.     $image,
  79.         
  80.     [Double]$left,
  81.     [Double]$top,
  82.    
  83.     [switch]$passThru                     
  84.     )
  85.    
  86.     process {
  87.         if (-not $filter) {
  88.             $filter = New-Object -ComObject Wia.ImageProcess
  89.         }
  90.         $index = $filter.Filters.Count + 1
  91.         if (-not $filter.Apply) { return }
  92.         $stamp = $filter.FilterInfos.Item("Stamp").FilterId                    
  93.         $filter.Filters.Add($stamp)
  94.         $filter.Filters.Item($index).Properties.Item("ImageFile") = $image.PSObject.BaseObject
  95.         $filter.Filters.Item($index).Properties.Item("Left") = $left
  96.         $filter.Filters.Item($index).Properties.Item("Top") = $top
  97.         if ($passthru) { return $filter }         
  98.     }
  99. }
复制代码

TOP

回复 2# Batcher


    老师,这个第三方插件咋用啊

TOP

回复 7# bao9688


    先下载,再安装,然后用2楼的BAT脚本。
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

回复 7# bao9688


其他类似的图片处理操作:
http://bbs.bathome.net/thread-60605-1-1.html#pid251524
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

回复 9# Batcher


    REM 根据自己电脑实际情况设置ImageMagick的路径
set "path=C:\Program Files\ImageMagick;%path%"
我不明白的是这个地方怎么设置。已经安装好了,安装路径是"D:\图片处理\ImageMagick-7.1.0-Q16-HDRI"

TOP

回复 9# Batcher


    正在处理文件夹:C:\Users\Administrator\Desktop\测试\1 [包含2个jpg图片]
'montage.exe' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
系统找不到指定的文件。
请按任意键继续. . .

TOP

回复 10# bao9688


    ImageMagick你安装到哪个路径下面了?
1

评分人数

我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

回复 12# Batcher


    安装路径是"D:\图片处理\ImageMagick-7.1.0-Q16-HDRI"

TOP

回复 13# bao9688


set "path=D:\图片处理\ImageMagick-7.1.0-Q16-HDRI;%path%"
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

回复 13# bao9688


如果还是那个报错,请检查你的 D:\图片处理\ImageMagick-7.1.0-Q16-HDRI 文件夹下是否有:montage.exe

如果仍有问题,请参考Q-01观察一下哪行代码在报错以及详细的报错信息:
https://mp.weixin.qq.com/s/6lbb97qUOs1sTyKJfN0ZEQ

如需上传截图,请用图床:
http://bbs.bathome.net/thread-60985-1-1.html

继续回帖讨论即可,不用给我发私信,谢谢。
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

返回列表