Инструменты пользователя

Инструменты сайта


progs:photo-soft

ImageMagick

Решение проблем

magick.exe: TIFF: negative image positions unsupported

Tif can't store negative offsets, so +repage is the usual cure for this.

Задачи

Конвертация bmp → jpg и запись комментариев внутрь jpg из текстового файла

Для PS7 и новее.

$folder = "C:\Users\jjj\Pictures\Альбом"
$info = gc "$folder\!Альбом.txt" -encoding 1251
cd $folder
 
# Качество 2-31, меньше лучше, но больше по размеру
dir $folder -Filter "*.bmp" |ForEach-Object -Parallel {
& ffmpeg -i "$($_.fullname)" -q:v 3 "$($_.basename).jpg"
} -ThrottleLimit $env:NUMBER_OF_PROCESSORS
 
# Пропись комментариев
$jpgs = dir "$folder" -Filter "*.jpg"
$info |% {
    & "C:\scripts\ImageMagick\mogrify.exe" -comment "$($_ -replace '^\d+-?\d? - ')" "$(($jpgs |? name -match ($_ -split ' - ')[0]).FullName)"
} 

https://stackoverflow.com/questions/28025017/how-to-store-description-in-jpeg-image

Пример содержимого текстового файла:

762 - Фото 26/X - 52 г. На память тете и дяде и сестре Любе от племянника Вовы.
763 - Чуркино, июнь 1952 г.
764 - Иван, родной брат Марии. 1915 г.
767-2 - Александра Павловна с мужем
769-2 - Лидия Павловна

Имена сканов:

img689.bmp
img690.bmp
img691.bmp
img692-1.bmp
img692-2.bmp
img692-3.bmp

RAW -> JPG

# Изменять размер только если картинка больше 1920 по какой-либо из сторон. Пропорции сохраняются.
# Учитывать ориентацию (чтобы jpg не были перевёрнутыми).
dir *.arw |% {
& magick.exe $_.fullname -auto-orient -resize 1920x1920> -quality 51 "D:\temp\in\ARW\$($_.basename).jpg"
}

JPG -> PDF

### Сканы паспорта
cd "C:\temp\passport"
# Нужны не все файлы в папке, иначе можно было бы указать *.bmp для magick.exe
$files = dir *.bmp |? basename -match 'img12[1-9]'
# 150 dpi, формат А4 (210x297mm / 8.27x11.69in / 595x842pt), поля 300 пикселей, jpeg-сжатие качеством 70
$dpi = 150
$a4 = "$(8.27*$dpi)x$(11.69*$dpi)"
 
& "C:\scripts\ImageMagick\magick.exe" `
$files.name -bordercolor white -border 300 `
-resize $a4 -gravity center -extent $a4 `
-compress jpeg -quality 70 `
"C:\temp\output$dpi.pdf"

https://acavalin.com/p/images_to_a4pdf

Вариант с GhostScript. Не так удобно, как с imagick: конвертировать в jpg и делать список входящих файлов надо заранее, поля не задаются.

cd "C:\temp\passport"
$jpgs = ((dir *.jpg).name |% { "`($_`) viewJPEG showpage" }) -join ' '
 
& 'C:\scripts\Ghostscript\bin\gswin64c.exe' `
-dNOSAFER -dNOPAUSE -dBATCH `
-sPAPERSIZE=a4 -sDEVICE=pdfwrite -o C:\temp\output.pdf `
C:\scripts\Ghostscript\lib\viewjpeg.ps `
-c "$jpgs"

DjVuLibre

djvu -> tiff

Каждая страница в отдельный файл

& "C:\Program Files (x86)\DjVuLibre\ddjvu.exe" -format=tiff -eachpage -skip `
"C:\temp\in\U_himii_svoi_zakonyi.djvu" "c:\temp\in\U_himii_svoi_zakonyi%03d.tiff"

Gimp

Resynthesizer / Heal selection

As an alternative for Windows, one from samj who make a portable gimp 2.10, same code but a more recent compile. Updated to partha versions

One thing that has been updated for Gimp 2.10 is the heal-selection.py plugin. The old one still works although newer version has updated some deprecated procedures.

64 bit version attached. Unzip, replace the existing, wherever you installed them. (~\AppData\Roaming\GIMP\2.10\plug-ins)

I suspect that it might be more than just an old-version problem.

Edit: Added an updated version
Edit: The samj version is 0.16c The Partha version is version 2 There is a difference in the resythesize-gui but not in functionality. For use with the 'heal-python plugins either work.
Edit: Some asking about the other plugins. If you need more than the two 'heal' plugins download the plugins zip.

Example of installation: https://youtu.be/JCbrXqVgttY 2 minutes, no audio

resynth.zip
resynth-partha.zip
resynth-python-plugins.zip

https://www.gimp-forum.net/Thread-Resynthisizer-Heal-Selection-Runtime-Error?pid=12687#pid12687

How to install Resynthesizer for Gimp 3 on Windows?
Step-by-Step Guide on How to install Resynthesizer Plugin in GIMP 3 for Win (Youtube)

Настройки

Сетка (View → Show grid) слишком мелкая, увеличить: Image → Configure grid...

ffmpeg

Вывести разрешение jpeg с помощью ffprobe

ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 input.jpg

https://superuser.com/questions/841235/how-do-i-use-ffmpeg-to-get-the-video-resolution

Фильтры

Автоуровни

# Автоуровень каждого канала независимо (порой даёт переэкспозицию)
-vf normalize
# Более осторожный вариант с выключением независимых автоуровней каждого канала
-vf normalize=independence=0
# Пример: уменьшение до 1920 и автоуровни
dir "~\Pictures\Продажа\2026.09.06 Обеденный стол" |% {
    ffmpeg -i $_.FullName -q:v 3 -vf scale=w=1920:h=1920:force_original_aspect_ratio=decrease,normalize "$($_.DirectoryName)\$($_.basename)-1920.jpg"
}

https://stackoverflow.com/questions/74261190/imagemagick-auto-level-in-ffmpeg

Ошибки, предупреждения

Warning: The specified filename does not contain an image sequence pattern or a pattern is invalid

Предупреждение, появляется при сжатии в jpeg.

[image2 @ 0000017d0d018c80] The specified filename 'IMG_20260906_100253-1920.jpg' does not contain an image sequence pattern or a pattern is invalid.
[image2 @ 0000017d0d018c80] Use a pattern such as %03d for an image sequence or use the -update option (with -frames:v 1 if needed) to write a single image.

Решение: добавить -update 1:

ffmpeg -y -i ".\IMG_20260906_100253.jpg" -q:v 3 -vf scale=w=1920:h=1920:force_original_aspect_ratio=decrease,normalize -update 1 ".\IMG_20260906_100253-1920.jpg"

https://superuser.com/questions/1792249/ffmpeg-suppress-warning-when-writing-to-a-single-image

Hugin

Сшивает панорамы. По сути, является GUI к Panorama tools.

Если сшивать отсканированные изображения, то у них нет EXIF, и Hugin запрашивает параметр HFOV (Horizontal field of view). В случае сканов надо вводить минимальное значение: 5 (в более современной статье по этой теме) или 10 (в старом мануале).

Ещё лучше сшивать сканы с помощью скрипта, т. к. там довольно много ручных параметров в режиме Expert.

Autostiching scan with Hugin
Hugin scan stitcher (command line)

$inputFiles = [System.Collections.Generic.List[object]]::new()
$args |% {
    $i = get-item -LiteralPath "$_"
    if ($i.mode -match "^d") {
        $inputFiles.AddRange($(dir $i.FullName -file -Recurse))
    }
    else {
        $inputFiles.add($i)
    }
}
 
$bin = "C:\Program Files\Hugin\bin"
 
$t = get-date -f "yyyyMMddHHmmss"
$prefix = "pano-$t"
$fov = 5 # Recommended values for scans are 1-10
cd $inputFiles[0].directoryname
 
& "$bin\pto_gen.exe" --projection=0 --fov=$fov -o $t-project.pto $inputFiles
& "$bin\pto_lensstack.exe" -o $t-project1.pto --new-lens i1 $t-project.pto
& "$bin\cpfind.exe" -o $t-project1.pto --multirow $t-project1.pto
& "$bin\cpclean.exe" -o $t-project2.pto $t-project1.pto
& "$bin\linefind.exe" -o $t-project3.pto $t-project2.pto
& "$bin\pto_var.exe" -o $t-setoptim.pto --opt r,d,e,!r0,!d0,!e0 $t-project3.pto
& "$bin\autooptimiser.exe" -n -o $t-autoptim.pto $t-setoptim.pto
& "$bin\pano_modify.exe" --projection=0 --fov=AUTO --center --canvas=AUTO --crop=AUTO -o $t-autoptim2.pto $t-autoptim.pto
& "$bin\hugin_executor.exe" -s $t-autoptim2.pto -p $prefix
 
# Remove *.pto files
del $t-*.pto
 
pause
progs/photo-soft.txt · Последнее изменение: — viacheslav

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki