{"id":328809,"date":"2022-01-30T21:00:07","date_gmt":"2022-01-30T21:00:07","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=328809"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=328809","title":{"rendered":"<span>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u0438 \u0441\u0442\u043e\u0440\u043e\u043d \u043d\u0430 Python<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441 <u>\u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u0438 \u0441\u0442\u043e\u0440\u043e\u043d<\/u>. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u0430\u0439\u043b\u043e\u0432. \u042d\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u043d\u0443\u0436\u043d\u0443\u044e \u043f\u0430\u043f\u043a\u0443, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0446\u0432\u0435\u0442 (\u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0441\u0446\u0438\u043b\u043b\u043e\u0433\u0440\u0430\u043c\u043c) \u0438 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0434\u043b\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0443\u0436\u0435 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043d\u043e \u0431\u044b\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0441\u0430\u043c\u043e\u043c\u0443. \u041f\u043e\u0434\u0435\u043b\u044e\u0441\u044c \u043a\u043e\u0434\u043e\u043c \u0441 \u0432\u0430\u043c\u0438, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043c\u0443-\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f (<strong>\u041a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438<\/strong>).<\/p>\n<h2>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/h2>\n<p>\u041f\u0435\u0440\u0434\u0438 \u043c\u043d\u043e\u0439 \u0441\u0442\u043e\u044f\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430, \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0443\u044e \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u0438 \u0441\u0442\u043e\u0440\u043e\u043d. \u0414\u043e\u043b\u0433\u043e \u043d\u0435\u0434\u0443\u043c\u0430\u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u043b \u0431\u044b \u0442\u0430\u043a\u0438\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438:<\/p>\n<ol>\n<li>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 (png, bmp, jpg \u0438 \u0442.\u0434.)<\/p>\n<\/li>\n<li>\n<p>\u0423\u0434\u043e\u0431\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0446\u0432\u0435\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>\u0423\u0434\u043e\u0431\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440 \u043f\u0443\u0442\u0438 \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/p>\n<\/li>\n<\/ol>\n<h2>\u0412\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434<\/h2>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0438 \u0447\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0441\u0430\u043c\u043e\u0439 <strong>\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/strong>.<\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" alt=\"\u0420\u0438\u0441. 1. \u0412\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434\" title=\"\u0420\u0438\u0441. 1. \u0412\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434\" height=\"462\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/291\/fcd\/601\/291fcd601ee0647ec3747f4d99738f5d.png\" data-width=\"339\"\/><figcaption>\u0420\u0438\u0441. 1. \u0412\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434<\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u0430 <strong>\u043b\u0438\u0448\u043d\u0438\u043c\u0438<\/strong> \u0434\u0435\u0442\u0430\u043b\u044f\u043c\u0438. \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435.<\/p>\n<ul>\n<li>\n<p><strong>Image files<\/strong> &#8212; \u0432\u044b\u0431\u043e\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041e\u0442\u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0432\u043e\u0434\u043d\u0438\u043a.<\/p>\n<\/li>\n<li>\n<p><strong>Save in folder<\/strong> &#8212; \u0432\u044b\u0431\u043e\u0440 \u043f\u0430\u043f\u043a\u0438 \u043a\u0443\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u0432\u044b\u0431\u0435\u0440\u0435\u0442 \u043f\u0430\u043f\u043a\u0443, \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u044b \u0432 \u043f\u0430\u043f\u043a\u0435 \u043a\u043e\u0440\u043d\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c Edited photos (\u043f\u0430\u043f\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438). \u041e\u0442\u043a\u0440\u043e\u0435\u0442\u0441\u044f <strong>\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439<\/strong> \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0432\u043e\u0434\u043d\u0438\u043a.<\/p>\n<\/li>\n<li>\n<p><strong>Image height (cm)<\/strong> &#8212; \u0437\u0434\u0435\u0441\u044c \u043d\u0443\u0436\u043d\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u0432\u044b\u0441\u043e\u0442\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 (\u0448\u0438\u0440\u0438\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u0439)<\/p>\n<\/li>\n<li>\n<p><strong>Inver color<\/strong> &#8212; \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u044d\u0442\u043e\u0433\u043e \u0447\u0435\u043a\u0431\u043e\u043a\u0441\u0430, \u0446\u0432\u0435\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0432 RGBA (<strong>\u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0435\u0441\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u043e\u0441\u0446\u0438\u043b\u043b\u043e\u0433\u0440\u0430\u043c\u043c<\/strong>)<\/p>\n<\/li>\n<li>\n<p><strong>Rename the file<\/strong> &#8212; \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0447\u0435\u043a\u0431\u043e\u043a\u0441\u0430 \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u043b\u0435 \u0432\u0432\u043e\u0434\u0430 &#171;<em>Add ending to file name<\/em>&#187; \u0438 \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0442\u0435\u043a\u0441\u0442. <br \/>\u041f\u0440\u0438\u043c\u0435\u0440: \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f &#171;x&#187;. \u0412 \u043f\u043e\u043b\u0435 <em>Add ending to file name <\/em>\u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c &#171;edit&#187;. \u0424\u0430\u0439\u043b \u0438\u043b\u0438 \u0444\u0430\u0439\u043b\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0441 \u0442\u0430\u043a\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c: &#171;x_edit&#187;. <br \/>\u0415\u0441\u043b\u0438 \u0447\u0435\u043a\u0431\u043e\u043a\u0441 \u043d\u0435 \u0432\u044b\u0431\u0440\u0430\u043d, \u0442\u043e \u0444\u0430\u0439\u043b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0441 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c (&#171;x&#187;)<\/p>\n<\/li>\n<li>\n<p><strong>Convert<\/strong> &#8212; \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0432\u044b\u0448\u0435.<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" alt=\"\u0420\u0438\u0441.2 \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b\" title=\"\u0420\u0438\u0441.2 \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b\" height=\"454\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/dbb\/f60\/be6\/dbbf60be64ffea88a5076a4b066030be.png\" data-width=\"668\"\/><figcaption>\u0420\u0438\u0441.2 \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/figcaption><\/figure>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/h2>\n<p>\u041a\u043e\u0434 \u0431\u044b\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 <strong>Python<\/strong> \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a:<\/p>\n<pre><code>from tkinter import * from tkinter import messagebox from tkinter import filedialog import PIL.ImageOps from PIL import Image import errno import os<\/code><\/pre>\n<p><strong>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0430 Python:<\/strong><\/p>\n<pre><code class=\"python\">from tkinter import * from tkinter import messagebox from tkinter import filedialog import PIL.ImageOps from PIL import Image import errno import os  ##--------------------------------------------------------------------------------------------------------------------## ##Creating a folder at the root of the program def make_sure_path_exists(path):     try: os.makedirs(path)     except OSError as exception:         if exception.errno != errno.EEXIST:             raise  ##\u0424\u0443function that translates from cm to pixel def cm_in_px(cm):     global px     px = int(cm) * 38     return px  ##Creating a folder at the root of the program-------------------------------------------------------------------------# make_sure_path_exists('Edited photos') #----------------------------------------------------------------------------------------------------------------------#  ##\u0424Scale and store aspect ratio def scale_image(input_image_path,                 output_image_path,                 width=None,                 height=None                 ):     original_image = Image.open(input_image_path)     w, h = original_image.size     print('The original image size is {wide} wide x {height} '           'high'.format(wide=w, height=h))      if width and height:         max_size = (width, height)     elif width:         max_size = (width, h)     elif height:         max_size = (w, height)     else:         # No width or height specified         raise RuntimeError('Width or height required!')      original_image.thumbnail(max_size, Image.ANTIALIAS)     original_image.save(output_image_path)      scaled_image = Image.open(output_image_path)     width, height = scaled_image.size     print('The scaled image size is {wide} wide x {height} '           'high'.format(wide=width, height=height)) #----------------------------------------------------------------------------------------------------------------------#  ##Signature checkbox 2 def chek_cb2():     global message_entry     if ismarried2.get() == 0:         message_entry = Entry(window, state=DISABLED, bd=2, width = 48)         message_entry.place(x=10, y=275)         return Label(window, text='Add ending to file name:', font=('Arial', 10)).place(x=10, y=250)     else:         message_entry = Entry(window, state=NORMAL, bd=2, width = 48)         message_entry.place(x=10, y=275)         return Label(window, text='Add ending to file name:', font=('Arial', 10)).place(x=10, y=250) #----------------------------------------------------------------------------------------------------------------------#  ##file renaming def rename():     global last_name     if ismarried2.get() == 1:         last_name = '_' + message_entry.get()     else:         last_name = ''     return last_name #----------------------------------------------------------------------------------------------------------------------#  #----------------------------------------------------------------------------------------------------------------------# ##Path to upload images number_f = 0 def clicked_dialogOpen():     global choosefile     global number_f     choosefile = filedialog.askopenfilename(multiple=True, parent = window, filetypes=((\"Image files\", \"*.png\"), (\"all files\", \"*.*\")))     number_f = len(choosefile)     label_file() #----------------------------------------------------------------------------------------------------------------------# ##Check for characters in the string def check_name():     global d     d = 0     for i in message_entry.get():         if i.isalpha():             d += 1         elif i.isdigit():             d+= 1         else:             d+= 1     return d #----------------------------------------------------------------------------------------------------------------------# ##Display information about the number of selected images def label_file():      if number_f == 0:         lbl2 = Label(window, text=\"Image not selected\", font=('Arial', 9), fg = 'red')         lbl2.place(x=start_pos_x, y=start_pos_y + step_des * 0.9)     elif number_f == 1:         lbl2 = Label(window, text='File selected             '.format(number_f), font=('Arial', 9), fg = 'green')         lbl2.place(x=start_pos_x, y=start_pos_y + step_des * 0.9)     else:         lbl2 = Label(window, text='Files selected - {}       '.format(number_f), font=('Arial', 9), fg = 'green')         lbl2.place(x=start_pos_x, y=start_pos_y + step_des * 0.9) #----------------------------------------------------------------------------------------------------------------------# ##Open the path to save the file filename = 0 def browse_button():     global filename     filename = filedialog.askdirectory()     label_folder() #----------------------------------------------------------------------------------------------------------------------# ##Display save directory information def label_folder():      if filename == 0:         lbl = Label(window, text=\"Path not selected\", font=('Arial', 9), fg = 'red')         lbl.place(x=start_pos_x, y=start_pos_y + step_des * 2.3)     elif filename == '':         lbl = Label(window, text=os.getcwd() + '\/Edited photos\/', font=('Arial', 9), fg = 'green')         lbl.place(x=start_pos_x, y=start_pos_y + step_des * 2.3)     else:         lbl = Label(window, text=filename, font=('Arial', 9), fg = 'green')         lbl.place(x=start_pos_x, y=start_pos_y + step_des * 2.3) #----------------------------------------------------------------------------------------------------------------------# ##Zoom and record an image def scale():     check_name()     if number_f &lt; 1:         messagebox.showerror(\"Error\", \"No file selected\")     if ismarried2.get() == 1 and d &lt; 1:         messagebox.showerror(\"Error\", \"Parameter not entered: Add ending to file name\")     else:         for i in range(number_f):             try:                 with open(choosefile[i]) as im:                     r = os.path.splitext(choosefile[i])                     var = (os.path.basename(r[0]), r[1])                      if filename == 0:                         folder = os.getcwd() + '\/Edited photos\/'                         output_name = folder + var[0] + rename() + var[1]                         scale_image(input_image_path=choosefile[i],                             output_image_path=output_name,                             height=cm_in_px(message_cm.get()))                          if ismarried.get() == 1:                             image = Image.open(output_name)                             if image.mode == 'RGBA':                                 r, g, b, a = image.split()                                 rgb_image = Image.merge('RGB', (r, g, b))                                 inverted_image = PIL.ImageOps.invert(rgb_image)                                 r2, g2, b2 = inverted_image.split()                                 final_transparent_image = Image.merge('RGBA', (r2, g2, b2, a))                                 final_transparent_image.save(output_name)                             else:                                 inverted_image = PIL.ImageOps.invert(image)                                 inverted_image.save(output_name)                      else:                         folder = filename                         output_name = filename + '\/' + var[0] + rename() + var[1]                         scale_image(input_image_path=choosefile[i],                             output_image_path = output_name,                             height=cm_in_px(message_cm.get()))                          if ismarried.get() == 1:                             image = Image.open(output_name)                             if image.mode == 'RGBA':                                 r, g, b, a = image.split()                                 rgb_image = Image.merge('RGB', (r, g, b))                                 inverted_image = PIL.ImageOps.invert(rgb_image)                                 r2, g2, b2 = inverted_image.split()                                 final_transparent_image = Image.merge('RGBA', (r2, g2, b2, a))                                 final_transparent_image.save(output_name)                             else:                                 inverted_image = PIL.ImageOps.invert(image)                                 inverted_image.save(output_name)                     print(\"\u00c7hose\",choosefile[0])             except:                 print('Error')                 messagebox.showerror(\"Error\", \"An error has occurred.\\n\\nThe program is intended for image processing only.\\n\\nContact the e-mail address:\\nolehlastovetskyi99@gmail.com\")                 quit()         messagebox.showinfo(\"Message\", \"Completed!\\nChanged {} files.\\nFiles saved in the directory:\\n{}\".format(number_f, folder)) #----------------------------------------------------------------------------------------------------------------------#  ##--------------------------------------------------------------------------------------------------------------------##  window = Tk() ismarried = IntVar(value= 2) ismarried.set(0) ismarried2 = IntVar(value= 2) ismarried2.set(0) chek_cb2() rename() ##------------------------------------------------------------------------------------------------------------------------##  start_pos_x = 10 start_pos_y = 10   height_button = 2 width_button = 32  font_button = (\"Arial Bold\", 11) font_checkbox = (\"Arial\", 11) font_combobox = ('Arial', 11) font_label = (\"Arial Bold\", 11) step_des = 60  label_folder() label_file()  window.title(\"Scale\")  btn_dialogOpen = Button(window, text=\"Image files\", command=clicked_dialogOpen, height=height_button,                         width=width_button, font=font_button) btn_dialogOpen.place(x=start_pos_x, y=start_pos_y)  btn_browsebutton = Button(window, text=\"Save in folder\", command=browse_button, height=height_button,                           width=width_button, font=font_button)  btn_browsebutton.place(x=start_pos_x, y=start_pos_y + step_des + 25)  lbl = Label(window, text=\"Image height (cm):\", font=font_label) lbl.place(x=start_pos_x + 1, y=start_pos_y + step_des * 2.95)  message_cm = Entry(width=7) message_cm.place(x=start_pos_x + 150, y=start_pos_y + step_des * 2.97) message_cm.insert(0, \"9\")  ismarried_checkbutton = Checkbutton(text=\"Invert color\", variable=ismarried, font =font_checkbox) ismarried_checkbutton.place(x=start_pos_x + 1, y=start_pos_y + step_des * 3.4)  ismarried_checkbutton2 = Checkbutton(text=\"Rename the file\", variable=ismarried2,                                      font = font_checkbox, command = chek_cb2) ismarried_checkbutton2.place(x=start_pos_x + 170, y=start_pos_y + step_des * 3.4)  btn_scale = Button(window, text=\"Convert\", command=scale, height=height_button, width=width_button,                    font=font_button, state = NORMAL)  btn_scale.place(x=start_pos_x, y=start_pos_y + step_des * 5.2)  Label(window, text='Github:', font=('Arial', 8)).place(x=10, y=385)  x = (window.winfo_screenwidth() - window.winfo_reqwidth()) \/ 2 y = (window.winfo_screenheight() - window.winfo_reqheight()) \/ 2 window.wm_geometry(\"+%d+%d\" % (x, y))  window.maxsize(320,410) window.minsize(320,410) window.resizable(0, 0)  window.mainloop() <\/code><\/pre>\n<p>\u0421\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 <strong>github<\/strong>:<a href=\"https:\/\/github.com\/Oleh-Last\/Python.git\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/Oleh-Last\/Python.git<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/648665\/\"> https:\/\/habr.com\/ru\/post\/648665\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441 <u>\u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u0438 \u0441\u0442\u043e\u0440\u043e\u043d<\/u>. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u0430\u0439\u043b\u043e\u0432. \u042d\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u043d\u0443\u0436\u043d\u0443\u044e \u043f\u0430\u043f\u043a\u0443, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0446\u0432\u0435\u0442 (\u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0441\u0446\u0438\u043b\u043b\u043e\u0433\u0440\u0430\u043c\u043c) \u0438 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0434\u043b\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0443\u0436\u0435 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043d\u043e \u0431\u044b\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0441\u0430\u043c\u043e\u043c\u0443. \u041f\u043e\u0434\u0435\u043b\u044e\u0441\u044c \u043a\u043e\u0434\u043e\u043c \u0441 \u0432\u0430\u043c\u0438, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043c\u0443-\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f (<strong>\u041a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438<\/strong>).<\/p>\n<h2>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/h2>\n<p>\u041f\u0435\u0440\u0434\u0438 \u043c\u043d\u043e\u0439 \u0441\u0442\u043e\u044f\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430, \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0443\u044e \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u0438 \u0441\u0442\u043e\u0440\u043e\u043d. \u0414\u043e\u043b\u0433\u043e \u043d\u0435\u0434\u0443\u043c\u0430\u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u043b \u0431\u044b \u0442\u0430\u043a\u0438\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438:<\/p>\n<ol>\n<li>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 (png, bmp, jpg \u0438 \u0442.\u0434.)<\/p>\n<\/li>\n<li>\n<p>\u0423\u0434\u043e\u0431\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0446\u0432\u0435\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>\u0423\u0434\u043e\u0431\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440 \u043f\u0443\u0442\u0438 \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/p>\n<\/li>\n<\/ol>\n<h2>\u0412\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434<\/h2>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0438 \u0447\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0441\u0430\u043c\u043e\u0439 <strong>\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/strong>.<\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"\"><figcaption>\u0420\u0438\u0441. 1. \u0412\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434<\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u0430 <strong>\u043b\u0438\u0448\u043d\u0438\u043c\u0438<\/strong> \u0434\u0435\u0442\u0430\u043b\u044f\u043c\u0438. \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435.<\/p>\n<ul>\n<li>\n<p><strong>Image files<\/strong> &#8212; \u0432\u044b\u0431\u043e\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041e\u0442\u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0432\u043e\u0434\u043d\u0438\u043a.<\/p>\n<\/li>\n<li>\n<p><strong>Save in folder<\/strong> &#8212; \u0432\u044b\u0431\u043e\u0440 \u043f\u0430\u043f\u043a\u0438 \u043a\u0443\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u0432\u044b\u0431\u0435\u0440\u0435\u0442 \u043f\u0430\u043f\u043a\u0443, \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u044b \u0432 \u043f\u0430\u043f\u043a\u0435 \u043a\u043e\u0440\u043d\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c Edited photos (\u043f\u0430\u043f\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438). \u041e\u0442\u043a\u0440\u043e\u0435\u0442\u0441\u044f <strong>\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439<\/strong> \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0432\u043e\u0434\u043d\u0438\u043a.<\/p>\n<\/li>\n<li>\n<p><strong>Image height (cm)<\/strong> &#8212; \u0437\u0434\u0435\u0441\u044c \u043d\u0443\u0436\u043d\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u0432\u044b\u0441\u043e\u0442\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 (\u0448\u0438\u0440\u0438\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u0439)<\/p>\n<\/li>\n<li>\n<p><strong>Inver color<\/strong> &#8212; \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u044d\u0442\u043e\u0433\u043e \u0447\u0435\u043a\u0431\u043e\u043a\u0441\u0430, \u0446\u0432\u0435\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0432 RGBA (<strong>\u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0435\u0441\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u043e\u0441\u0446\u0438\u043b\u043b\u043e\u0433\u0440\u0430\u043c\u043c<\/strong>)<\/p>\n<\/li>\n<li>\n<p><strong>Rename the file<\/strong> &#8212; \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0447\u0435\u043a\u0431\u043e\u043a\u0441\u0430 \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u043b\u0435 \u0432\u0432\u043e\u0434\u0430 &#171;<em>Add ending to file name<\/em>&#187; \u0438 \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0442\u0435\u043a\u0441\u0442. <br \/>\u041f\u0440\u0438\u043c\u0435\u0440: \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f &#171;x&#187;. \u0412 \u043f\u043e\u043b\u0435 <em>Add ending to file name <\/em>\u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c &#171;edit&#187;. \u0424\u0430\u0439\u043b \u0438\u043b\u0438 \u0444\u0430\u0439\u043b\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0441 \u0442\u0430\u043a\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c: &#171;x_edit&#187;. <br \/>\u0415\u0441\u043b\u0438 \u0447\u0435\u043a\u0431\u043e\u043a\u0441 \u043d\u0435 \u0432\u044b\u0431\u0440\u0430\u043d, \u0442\u043e \u0444\u0430\u0439\u043b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0441 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c (&#171;x&#187;)<\/p>\n<\/li>\n<li>\n<p><strong>Convert<\/strong> &#8212; \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0432\u044b\u0448\u0435.<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><figcaption>\u0420\u0438\u0441.2 \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/figcaption><\/figure>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/h2>\n<p>\u041a\u043e\u0434 \u0431\u044b\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 <strong>Python<\/strong> \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a:<\/p>\n<pre><code>from tkinter import * from tkinter import messagebox from tkinter import filedialog import PIL.ImageOps from PIL import Image import errno import os<\/code><\/pre>\n<p><strong>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0430 Python:<\/strong><\/p>\n<pre><code class=\"python\">from tkinter import * from tkinter import messagebox from tkinter import filedialog import PIL.ImageOps from PIL import Image import errno import os  ##--------------------------------------------------------------------------------------------------------------------## ##Creating a folder at the root of the program def make_sure_path_exists(path):     try: os.makedirs(path)     except OSError as exception:         if exception.errno != errno.EEXIST:             raise  ##\u0424\u0443function that translates from cm to pixel def cm_in_px(cm):     global px     px = int(cm) * 38     return px  ##Creating a folder at the root of the program-------------------------------------------------------------------------# make_sure_path_exists('Edited photos') #----------------------------------------------------------------------------------------------------------------------#  ##\u0424Scale and store aspect ratio def scale_image(input_image_path,                 output_image_path,                 width=None,                 height=None                 ):     original_image = Image.open(input_image_path)     w, h = original_image.size     print('The original image size is {wide} wide x {height} '           'high'.format(wide=w, height=h))      if width and height:         max_size = (width, height)     elif width:         max_size = (width, h)     elif height:         max_size = (w, height)     else:         # No width or height specified         raise RuntimeError('Width or height required!')      original_image.thumbnail(max_size, Image.ANTIALIAS)     original_image.save(output_image_path)      scaled_image = Image.open(output_image_path)     width, height = scaled_image.size     print('The scaled image size is {wide} wide x {height} '           'high'.format(wide=width, height=height)) #----------------------------------------------------------------------------------------------------------------------#  ##Signature checkbox 2 def chek_cb2():     global message_entry     if ismarried2.get() == 0:         message_entry = Entry(window, state=DISABLED, bd=2, width = 48)         message_entry.place(x=10, y=275)         return Label(window, text='Add ending to file name:', font=('Arial', 10)).place(x=10, y=250)     else:         message_entry = Entry(window, state=NORMAL, bd=2, width = 48)         message_entry.place(x=10, y=275)         return Label(window, text='Add ending to file name:', font=('Arial', 10)).place(x=10, y=250) #----------------------------------------------------------------------------------------------------------------------#  ##file renaming def rename():     global last_name     if ismarried2.get() == 1:         last_name = '_' + message_entry.get()     else:         last_name = ''     return last_name #----------------------------------------------------------------------------------------------------------------------#  #----------------------------------------------------------------------------------------------------------------------# ##Path to upload images number_f = 0 def clicked_dialogOpen():     global choosefile     global number_f     choosefile = filedialog.askopenfilename(multiple=True, parent = window, filetypes=((\"Image files\", \"*.png\"), (\"all files\", \"*.*\")))     number_f = len(choosefile)     label_file() #----------------------------------------------------------------------------------------------------------------------# ##Check for characters in the string def check_name():     global d     d = 0     for i in message_entry.get():         if i.isalpha():             d += 1         elif i.isdigit():             d+= 1         else:             d+= 1     return d #----------------------------------------------------------------------------------------------------------------------# ##Display information about the number of selected images def label_file():      if number_f == 0:         lbl2 = Label(window, text=\"Image not selected\", font=('Arial', 9), fg = 'red')         lbl2.place(x=start_pos_x, y=start_pos_y + step_des * 0.9)     elif number_f == 1:         lbl2 = Label(window, text='File selected             '.format(number_f), font=('Arial', 9), fg = 'green')         lbl2.place(x=start_pos_x, y=start_pos_y + step_des * 0.9)     else:         lbl2 = Label(window, text='Files selected - {}       '.format(number_f), font=('Arial', 9), fg = 'green')         lbl2.place(x=start_pos_x, y=start_pos_y + step_des * 0.9) #----------------------------------------------------------------------------------------------------------------------# ##Open the path to save the file filename = 0 def browse_button():     global filename     filename = filedialog.askdirectory()     label_folder() #----------------------------------------------------------------------------------------------------------------------# ##Display save directory information def label_folder():      if filename == 0:         lbl = Label(window, text=\"Path not selected\", font=('Arial', 9), fg = 'red')         lbl.place(x=start_pos_x, y=start_pos_y + step_des * 2.3)     elif filename == '':         lbl = Label(window, text=os.getcwd() + '\/Edited photos\/', font=('Arial', 9), fg = 'green')         lbl.place(x=start_pos_x, y=start_pos_y + step_des * 2.3)     else:         lbl = Label(window, text=filename, font=('Arial', 9), fg = 'green')         lbl.place(x=start_pos_x, y=start_pos_y + step_des * 2.3) #----------------------------------------------------------------------------------------------------------------------# ##Zoom and record an image def scale():     check_name()     if number_f &lt; 1:         messagebox.showerror(\"Error\", \"No file selected\")     if ismarried2.get() == 1 and d &lt; 1:         messagebox.showerror(\"Error\", \"Parameter not entered: Add ending to file name\")     else:         for i in range(number_f):             try:                 with open(choosefile[i]) as im:                     r = os.path.splitext(choosefile[i])                     var = (os.path.basename(r[0]), r[1])                      if filename == 0:                         folder = os.getcwd() + '\/Edited photos\/'                         output_name = folder + var[0] + rename() + var[1]                         scale_image(input_image_path=choosefile[i],                             output_image_path=output_name,                             height=cm_in_px(message_cm.get()))                          if ismarried.get() == 1:                             image = Image.open(output_name)                             if image.mode == 'RGBA':                                 r, g, b, a = image.split()                                 rgb_image = Image.merge('RGB', (r, g, b))                                 inverted_image = PIL.ImageOps.invert(rgb_image)                                 r2, g2, b2 = inverted_image.split()                                 final_transparent_image = Image.merge('RGBA', (r2, g2, b2, a))                                 final_transparent_image.save(output_name)                             else:                                 inverted_image = PIL.ImageOps.invert(image)                                 inverted_image.save(output_name)                      else:                         folder = filename                         output_name = filename + '\/' + var[0] + rename() + var[1]<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-328809","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/328809","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=328809"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/328809\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=328809"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=328809"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=328809"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}