diff --git a/press-n-post b/press-n-post index 3cb006e..e0504ba 100755 --- a/press-n-post +++ b/press-n-post @@ -3,6 +3,7 @@ package require Tk package require Img package require fileutil +package require textutil package require platform #---------------------------------------------------------------------- @@ -160,7 +161,12 @@ namespace eval pdf { # # Фамилия_1 И.О., Фамилия_2 И.О. - Название работы.pdf # - if {![regexp {(.*) - (.*)} $file_basename {} authors title]} { + set authors_title [::textutil::splitx $file_basename " - "] + + if {[llength $authors_title] >= 2} { + set authors [lindex $authors_title 0] + set title [join [lrange $authors_title 1 end] " - "] + } else { set authors {} set title $file_basename } @@ -326,12 +332,19 @@ namespace eval cover { # Создание webp-вариантов изображений proc make_webp {} { catch {exec cwebp "${::pdf::file_rootname}.jpg" -o "${::pdf::file_rootname}.webp" >/dev/null} - catch {exec cwebp "${::pdf::file_rootname}.th.jpg" -o "${::pdf::file_rootname}.th.webp" >/dev/null} + + if {[file exists ${::pdf::file_rootname}.th.jpg]} { + catch {exec cwebp "${::pdf::file_rootname}.th.jpg" -o "${::pdf::file_rootname}.th.webp" >/dev/null} + } } # Оптимизация изображений proc optimize {} { - exec resmushit-cli --preserve-filename "${::pdf::file_rootname}.jpg" + exec resmushit-cli --preserve-filename "${::pdf::file_rootname}.jpg" >/dev/null + + if {[file exists ${::pdf::file_rootname}.th.jpg]} { + exec resmushit-cli --preserve-filename "${::pdf::file_rootname}.th.jpg" + } } # TODO: Обрезка изображения