Commit 5474342e by 高宇强

gyq

parent 76520487
......@@ -14,14 +14,11 @@
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="CreateScene.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/CreateScene.py">
<file leaf-file-name="LogoManage.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/../../6126上/opencvTest/LogoManage.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="171">
<caret line="9" lean-forward="true" selection-start-line="9" selection-end-line="9" />
<folding>
<element signature="e#46#61#0" expanded="true" />
</folding>
<state relative-caret-position="209">
<caret line="11" selection-start-line="11" selection-end-line="11" selection-end-column="21" />
</state>
</provider>
</entry>
......@@ -29,10 +26,8 @@
<file leaf-file-name="GetLogo.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/GetLogo.py">
<provider selected="true" editor-type-id="text-editor">
<state>
<folding>
<element signature="e#165#189#0" expanded="true" />
</folding>
<state relative-caret-position="133">
<caret line="7" column="24" selection-start-line="7" selection-start-column="24" selection-end-line="7" selection-end-column="24" />
</state>
</provider>
</entry>
......@@ -40,7 +35,8 @@
<file leaf-file-name="LogoBaseGenerator.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/LogoBaseGenerator.py">
<provider selected="true" editor-type-id="text-editor">
<state>
<state relative-caret-position="323">
<caret line="350" column="27" lean-forward="true" selection-start-line="350" selection-start-column="27" selection-end-line="350" selection-end-column="27" />
<folding>
<element signature="e#156#197#0" expanded="true" />
</folding>
......@@ -48,11 +44,29 @@
</provider>
</entry>
</file>
<file leaf-file-name="builders.py" pinned="false" current-in-tab="true">
<entry file="file://E:/Program Files/Python37/Lib/site-packages/pysvg/builders.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="224">
<caret line="329" selection-start-line="329" selection-end-line="331" selection-end-column="69" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="LogoParseFonts.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/LogoParseFonts.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="114">
<caret line="6" column="14" selection-start-line="6" selection-start-column="5" selection-end-line="6" selection-end-column="14" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="LogoGenerator.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/LogoGenerator.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1615">
<caret line="14" column="27" selection-start-line="14" selection-start-column="27" selection-end-line="14" selection-end-column="27" />
<state relative-caret-position="247">
<caret line="18" column="8" selection-start-line="18" selection-start-column="8" selection-end-line="18" selection-end-column="8" />
<folding>
<element signature="e#157#178#0" expanded="true" />
</folding>
......@@ -60,16 +74,14 @@
</provider>
</entry>
</file>
<file leaf-file-name="LogoReqAnalysis.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/LogoReqAnalysis.py">
<provider selected="true" editor-type-id="text-editor" />
</entry>
</file>
<file leaf-file-name="LogoUtil.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/LogoUtil.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="114">
<caret line="6" column="29" selection-start-line="6" selection-start-column="27" selection-end-line="6" selection-end-column="34" />
<state relative-caret-position="1292">
<caret line="69" column="20" selection-start-line="69" selection-start-column="11" selection-end-line="69" selection-end-column="20" />
<folding>
<element signature="e#147#188#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
......@@ -77,8 +89,8 @@
<file leaf-file-name="main.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="380">
<caret line="20" column="49" lean-forward="true" selection-start-line="20" selection-start-column="49" selection-end-line="20" selection-end-column="49" />
<state relative-caret-position="3781">
<caret line="205" column="42" selection-start-line="205" selection-start-column="42" selection-end-line="205" selection-end-column="42" />
<folding>
<element signature="e#166#215#0" expanded="true" />
</folding>
......@@ -89,27 +101,17 @@
<file leaf-file-name="LogoManage.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/LogoManage.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="187">
<caret line="407" column="78" lean-forward="true" selection-start-line="407" selection-start-column="78" selection-end-line="407" selection-end-column="78" />
<folding>
<element signature="e#54#76#0" expanded="true" />
</folding>
<state relative-caret-position="209">
<caret line="11" column="13" selection-start-line="11" selection-start-column="13" selection-end-line="11" selection-end-column="13" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="main.py" pinned="false" current-in-tab="true">
<entry file="file://E:/gitproject/zhichan/ailogo/main.py">
<file leaf-file-name="parseFonts.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/parseFonts.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-2714" />
</provider>
</entry>
</file>
<file leaf-file-name="api.py" pinned="false" current-in-tab="false">
<entry file="file://E:/Program Files/Python37/Lib/site-packages/requests/api.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="186">
<caret line="103" column="4" selection-start-line="103" selection-start-column="4" selection-end-line="103" selection-end-column="4" />
<state relative-caret-position="285">
<caret line="15" column="22" lean-forward="true" selection-start-line="15" selection-start-column="22" selection-end-line="15" selection-end-column="22" />
</state>
</provider>
</entry>
......@@ -127,6 +129,7 @@
<find>show()</find>
<find>SaveSingleLogo</find>
<find>c_url = 'http://127.0.0.1:5000/api/createlogo'</find>
<find>127.0</find>
</findStrings>
</component>
<component name="IdeDocumentHistory">
......@@ -135,14 +138,18 @@
<option value="$PROJECT_DIR$/LogoReqAnalysis.py" />
<option value="$PROJECT_DIR$/LogoBaseGenerator.py" />
<option value="$PROJECT_DIR$/LogoGenerator.py" />
<option value="$PROJECT_DIR$/GetLogo.py" />
<option value="$PROJECT_DIR$/customizelogosmall.py" />
<option value="$PROJECT_DIR$/CreateScene.py" />
<option value="$PROJECT_DIR$/../../线上/opencvTest/LogoManage.py" />
<option value="$PROJECT_DIR$/LogoServers.py" />
<option value="$PROJECT_DIR$/../opencvTest/LogoManage.py" />
<option value="$PROJECT_DIR$/LogoManage.py" />
<option value="$PROJECT_DIR$/main.py" />
<option value="$PROJECT_DIR$/../../../专利报告/testecharts.py" />
<option value="$PROJECT_DIR$/../../../证照/online_report/report_sj.py" />
<option value="$PROJECT_DIR$/CreateScene.py" />
<option value="E:/gitproject/zhichan/ailogo/LogoManage.py" />
<option value="K:/opencvTest-server-v/LogoManage.py" />
<option value="$PROJECT_DIR$/GetLogo.py" />
<option value="$PROJECT_DIR$/LogoManage.py" />
</list>
</option>
</component>
......@@ -155,7 +162,7 @@
<component name="NodePackageJsonFileManager">
<packageJsonPaths />
</component>
<component name="ProjectFrameBounds" extendedState="6">
<component name="ProjectFrameBounds" extendedState="7">
<option name="x" value="-8" />
<option name="y" value="-8" />
<option name="width" value="1382" />
......@@ -166,7 +173,6 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
......@@ -178,6 +184,7 @@
<select />
</subPane>
</pane>
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
......@@ -277,23 +284,23 @@
<servers />
</component>
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="1382" height="744" extended-state="6" />
<frame x="-8" y="-8" width="1382" height="744" extended-state="7" />
<editor active="true" />
<layout>
<window_info anchor="bottom" id="TODO" order="10" />
<window_info anchor="bottom" id="Event Log" order="0" side_tool="true" />
<window_info anchor="bottom" id="Database Changes" order="11" show_stripe_button="false" />
<window_info anchor="bottom" id="Run" order="6" weight="0.6375991" />
<window_info anchor="bottom" id="Version Control" order="1" show_stripe_button="false" />
<window_info anchor="bottom" id="Python Console" order="2" />
<window_info anchor="bottom" id="Run" order="6" weight="0.6375991" />
<window_info anchor="bottom" id="Terminal" order="3" weight="0.32930845" />
<window_info active="true" content_ui="combo" id="Project" order="1" visible="true" weight="0.22541603" />
<window_info active="true" content_ui="combo" id="Project" order="1" visible="true" weight="0.2473525" />
<window_info anchor="bottom" id="Docker" order="11" show_stripe_button="false" />
<window_info anchor="right" id="Database" order="3" />
<window_info anchor="right" id="SciView" order="3" />
<window_info id="Structure" order="2" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Debug" order="7" weight="0.4" />
<window_info id="Favorites" order="0" side_tool="true" />
<window_info anchor="bottom" id="Debug" order="7" weight="0.4" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="9" weight="0.4" />
<window_info anchor="right" id="Commander" order="0" weight="0.4" />
......@@ -317,11 +324,6 @@
<line>105</line>
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/LogoBaseGenerator.py</url>
<line>196</line>
<option name="timeStamp" value="1" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/customizelogosmall.py</url>
<line>395</line>
<option name="timeStamp" value="2" />
......@@ -334,97 +336,6 @@
<entry file="file://$PROJECT_DIR$/LogoGenerator.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="171">
<caret line="14" column="27" selection-start-line="14" selection-start-column="27" selection-end-line="14" selection-end-column="27" />
<folding>
<element signature="e#157#178#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/LogoReqAnalysis.py">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/LogoUtil.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="114">
<caret line="6" column="29" selection-start-line="6" selection-start-column="27" selection-end-line="6" selection-end-column="34" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/SceneGeneratorServer.py">
<provider selected="true" editor-type-id="text-editor">
<state>
<folding>
<element signature="e#159#189#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="741">
<caret line="45" column="59" lean-forward="true" selection-start-line="45" selection-start-column="59" selection-end-line="45" selection-end-column="59" />
<folding>
<element signature="e#166#215#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/LogoManage.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="8227">
<caret line="440" column="31" lean-forward="true" selection-start-line="440" selection-start-column="31" selection-end-line="440" selection-end-column="31" />
<folding>
<element signature="e#54#76#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/CreateScene.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="76">
<caret line="4" column="22" selection-start-line="4" selection-start-column="7" selection-end-line="4" selection-end-column="22" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/LogoUtil.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="114">
<caret line="6" column="29" selection-start-line="6" selection-start-column="27" selection-end-line="6" selection-end-column="34" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/SceneGeneratorServer.py">
<provider selected="true" editor-type-id="text-editor">
<state>
<folding>
<element signature="e#159#189#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor">
<state>
<folding>
<element signature="e#166#215#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/LogoManage.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="532">
<caret line="35" column="55" selection-start-line="35" selection-start-column="55" selection-end-line="35" selection-end-column="55" />
<folding>
<element signature="e#54#76#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/LogoGenerator.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="171">
<caret line="14" column="27" lean-forward="true" selection-start-line="14" selection-start-column="27" selection-end-line="14" selection-end-column="27" />
<folding>
<element signature="e#157#178#0" expanded="true" />
......@@ -439,9 +350,6 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="665">
<caret line="35" column="55" lean-forward="true" selection-start-line="35" selection-start-column="55" selection-end-line="35" selection-end-column="55" />
<folding>
<element signature="e#54#76#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
......@@ -478,12 +386,37 @@
<entry file="file://$PROJECT_DIR$/SceneGeneratorServer.py" />
<entry file="file://$PROJECT_DIR$/LogoGenerator.py" />
<entry file="file://$PROJECT_DIR$/LogoServers.py" />
<entry file="file://$PROJECT_DIR$/SceneGeneratorServer.py">
<entry file="file://$PROJECT_DIR$/../opencvTest/LogoManage.py" />
<entry file="file://E:/Program Files/Python37/Lib/site-packages/requests/api.py">
<provider selected="true" editor-type-id="text-editor">
<state>
<folding>
<element signature="e#159#189#0" expanded="true" />
</folding>
<state relative-caret-position="1957">
<caret line="103" column="4" selection-start-line="103" selection-start-column="4" selection-end-line="103" selection-end-column="4" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../../线上/opencvTest/LogoManage.py" />
<entry file="file://$PROJECT_DIR$/LogoReqAnalysis.py" />
<entry file="file://E:/gitproject/zhichan/ailogo/main.py">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/../../../专利报告/testecharts.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="209">
<caret line="39" column="43" selection-start-line="39" selection-start-column="43" selection-end-line="39" selection-end-column="43" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../../../证照/online_report/report_sj.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="190">
<caret line="206" column="92" selection-start-line="206" selection-start-column="79" selection-end-line="206" selection-end-column="92" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/CreateScene.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="399">
<caret line="21" column="28" selection-start-line="21" selection-start-column="28" selection-end-line="21" selection-end-column="28" />
</state>
</provider>
</entry>
......@@ -496,98 +429,114 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/SceneGeneratorServer.py">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://K:/opencvTest-server-v/main.py" />
<entry file="file://K:/opencvTest-server-v/LogoManage.py" />
<entry file="file://E:/gitproject/zhichan/ailogo/LogoManage.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="160">
<caret line="559" column="29" selection-start-line="559" selection-start-column="22" selection-end-line="559" selection-end-column="29" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/GetLogo.py">
<provider selected="true" editor-type-id="text-editor">
<state>
<folding>
<element signature="e#165#189#0" expanded="true" />
</folding>
<state relative-caret-position="133">
<caret line="7" column="24" selection-start-line="7" selection-start-column="24" selection-end-line="7" selection-end-column="24" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/LogoBaseGenerator.py">
<entry file="file://$PROJECT_DIR$/LogoGenerator.py">
<provider selected="true" editor-type-id="text-editor">
<state>
<state relative-caret-position="247">
<caret line="18" column="8" selection-start-line="18" selection-start-column="8" selection-end-line="18" selection-end-column="8" />
<folding>
<element signature="e#156#197#0" expanded="true" />
<element signature="e#157#178#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/LogoUtil.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="114">
<caret line="6" column="29" selection-start-line="6" selection-start-column="27" selection-end-line="6" selection-end-column="34" />
<state relative-caret-position="1292">
<caret line="69" column="20" selection-start-line="69" selection-start-column="11" selection-end-line="69" selection-end-column="20" />
<folding>
<element signature="e#147#188#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../opencvTest/LogoManage.py">
<entry file="file://$PROJECT_DIR$/../../../paramikotest.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="304">
<caret line="38" column="79" selection-start-line="38" selection-start-column="79" selection-end-line="38" selection-end-column="79" />
<state relative-caret-position="1045">
<caret line="55" column="24" selection-start-line="55" selection-start-column="24" selection-end-line="55" selection-end-column="24" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/LogoGenerator.py">
<entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1615">
<caret line="14" column="27" selection-start-line="14" selection-start-column="27" selection-end-line="14" selection-end-column="27" />
<state relative-caret-position="3781">
<caret line="205" column="42" selection-start-line="205" selection-start-column="42" selection-end-line="205" selection-end-column="42" />
<folding>
<element signature="e#157#178#0" expanded="true" />
<element signature="e#166#215#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://E:/Program Files/Python37/Lib/site-packages/requests/api.py">
<entry file="file://$PROJECT_DIR$/../../6126上/opencvTest/LogoManage.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="186">
<caret line="103" column="4" selection-start-line="103" selection-start-column="4" selection-end-line="103" selection-end-column="4" />
<state relative-caret-position="209">
<caret line="11" selection-start-line="11" selection-end-line="11" selection-end-column="21" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../../线上/opencvTest/LogoManage.py">
<entry file="file://$PROJECT_DIR$/parseFonts.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-9416">
<caret line="38" column="79" lean-forward="true" selection-start-line="38" selection-start-column="12" selection-end-line="38" selection-end-column="79" />
<state relative-caret-position="285">
<caret line="15" column="22" lean-forward="true" selection-start-line="15" selection-start-column="22" selection-end-line="15" selection-end-column="22" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/CreateScene.py">
<entry file="file://$PROJECT_DIR$/LogoManage.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="171">
<caret line="9" lean-forward="true" selection-start-line="9" selection-end-line="9" />
<folding>
<element signature="e#46#61#0" expanded="true" />
</folding>
<state relative-caret-position="209">
<caret line="11" column="13" selection-start-line="11" selection-start-column="13" selection-end-line="11" selection-end-column="13" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/main.py">
<entry file="file://E:/Program Files/Python37/Lib/site-packages/fontTools/__init__.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="380">
<caret line="20" column="49" lean-forward="true" selection-start-line="20" selection-start-column="49" selection-end-line="20" selection-end-column="49" />
<state>
<folding>
<element signature="e#166#215#0" expanded="true" />
<element signature="e#0#33#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/LogoReqAnalysis.py">
<provider selected="true" editor-type-id="text-editor" />
<entry file="file://$PROJECT_DIR$/LogoParseFonts.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="114">
<caret line="6" column="14" selection-start-line="6" selection-start-column="5" selection-end-line="6" selection-end-column="14" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/LogoManage.py">
<entry file="file://$PROJECT_DIR$/LogoBaseGenerator.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="187">
<caret line="407" column="78" lean-forward="true" selection-start-line="407" selection-start-column="78" selection-end-line="407" selection-end-column="78" />
<state relative-caret-position="323">
<caret line="350" column="27" lean-forward="true" selection-start-line="350" selection-start-column="27" selection-end-line="350" selection-end-column="27" />
<folding>
<element signature="e#54#76#0" expanded="true" />
<element signature="e#156#197#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://E:/gitproject/zhichan/ailogo/main.py">
<entry file="file://E:/Program Files/Python37/Lib/site-packages/pysvg/builders.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-2714" />
<state relative-caret-position="224">
<caret line="329" selection-start-line="329" selection-end-line="331" selection-end-column="69" />
</state>
</provider>
</entry>
</component>
......
......@@ -46,6 +46,13 @@ def getLogoUrl(inputdata):
imagepath = pic1["name"]
font_url = 'font/cn/' + imagepath
if type == "standard":
# 获取svg的url地址
svg_url = ""
select_url = 'select pic_url from logo_svg where png_id =%s' % log_id
cur.execute(select_url)
pic2 = cur.fetchone()
if pic2:
svg_url = pic2["pic_url"]
gen_json = {
'brand_text': brand_text, # 品牌名称
'brand_color': brand_color, # 字体颜色
......@@ -53,7 +60,8 @@ def getLogoUrl(inputdata):
'slogan_text': slogan_text, # 标语名称,可以为空
'slogan_color': slogan_color, # 标语颜色
'logo_url': logo_url, # 图片地址
'brand_font': font_url # 字体路径
'brand_font': font_url, # 字体路径
'svg_url':svg_url #svg的url路径
}
# 生成6个图片
......@@ -76,7 +84,6 @@ def getLogoUrl(inputdata):
'brand_font': font_url, # 字体路径
'model_id': model_id
}
print(str(gen_json))
pic_all = CustomizeBaseLogo.down_customize_logo(gen_json)
......
......@@ -5,8 +5,13 @@
# @File : LogoBaseGenerator.py
# @Software: PyCharm
from PIL import Image,ImageDraw,ImageFont
import os,time
import os,time,random,re
from LogoUtil import downlogo,alpha2white,make_zip,downlogo_path,put2oss
from fontTools.ttLib import TTFont
from pysvg import parser
from pysvg.builders import TransformBuilder,StyleBuilder,Path,G,Svg,ShapeBuilder
from parseFonts import brandFont, sloganFont
'''
logo基础生成
1.白底黑字
......@@ -189,6 +194,352 @@ class LogoBaseGen():
#创建svg文件的类
class generatorSvg:
def __init__(self):
self.width = 380
self.height = 280
self.oh = ShapeBuilder()
# 创建svg图像,品牌语和标语都存在
def create_svg_brand_slogan(self, brand_result,brand_coordinate, brand_color, brand_location, slogan_result,slogan_coordinate, slogan_color,style_svg):
# 创建一个空白的svg
svg_logo = Svg(height="100%", width="100%")
# svg展示窗口大小
svg_logo.set_viewBox('0,0,380,280')
# 给窗口添加一个颜色,更直观
# bc_rect = self.oh.createRect(0, 0, 380, 280, fill='#FFFAE3')
# svg_logo.addElement(bc_rect)
#创建品牌语风格
brand_style = StyleBuilder()
brand_style.setFilling(fill=brand_color)
#创建标语风格
slogan_style = StyleBuilder()
slogan_style.setFilling(fill=slogan_color)
# 遍历品牌语svg字体
brand_elements = []
for res in brand_result:
sub_group = G()
# sub_group.set_id(res['name'])
sub_group.set_style(brand_style.getStyle())
sub_path = Path(res['path_d'], style=brand_style.getStyle())
# sub_path.set_id('nn')
# sub_path.set_style(brandstyle.getStyle())
sub_group.addElement(sub_path)
brand_elements.append(sub_group)
# 遍历标语svg字体
slogan_elements = []
for res in slogan_result:
sub_group = G()
sub_group.set_id(res['name'])
sub_group.set_style(slogan_style.getStyle())
sub_path = Path(res['path_d'], style=slogan_style.getStyle())
# sub_path.set_id('nn')
sub_group.addElement(sub_path)
slogan_elements.append(sub_group)
# 品牌语的长度
brand_width = brand_coordinate[0]
brand_height = brand_coordinate[1]
# print(brand_coordinate[0], brand_coordinate[1])
# 标语的长度
slogan_width = slogan_coordinate[0]
slogan_height = slogan_coordinate[1]
# 找到最大长度的文本
max_length = max(brand_width, slogan_width)
#对logo图像进行加载
logo_svg_read = parser.parse(style_svg)
logo_svg_read.set_width("100")
logo_svg_read.set_height("100")
#定义品牌语图层
brand_group = G()
brand_th = TransformBuilder()
#定义标语图层
slogan_group = G()
slogan_th = TransformBuilder()
# 创建logo样式图层
logo_group = G()
img_th = TransformBuilder()
#判断图样与文字的位置关系
if brand_location=='右':
# 品牌语计算位置坐标
brand_start_x = 230 - int(brand_width / 2)
brand_start_y = 140 - int((abs(brand_height) + abs(slogan_height)) / 2) + abs(brand_height)
print(brand_start_x)
brand_th.setTranslation(brand_start_x,brand_start_y)
brand_group.set_transform(brand_th.getTransform())
# bb = self.oh.createCircle(brand_start_x, brand_start_y, 2, fill='orange')
# 插入品牌语字体
for el in brand_elements:
brand_group.addElement(el)
#标语计算位置坐标
slogan_start_x = 230 - int(slogan_width / 2)
slogan_start_y = brand_start_y
slogan_th.setTranslation(slogan_start_x, slogan_start_y)
slogan_group.set_transform(slogan_th.getTransform())
# ss = self.oh.createCircle(slogan_start_x, brand_start_y, 2, fill='white')
# 插入标语字体
for el in slogan_elements:
slogan_group.addElement(el)
#logo图样计算位置坐标
img_start_x = 190 - int((100 + max_length) / 2)
img_th.setTranslation(img_start_x, 90)
# bc_rect = self.oh.createRect(0, 0, 100, 100, fill='yellow')
# logo_group.addElement(bc_rect)
logo_group.set_transform(img_th.getTransform())
if brand_location=='左':
# 品牌语计算位置坐标
brand_start_x = 130 - int(brand_width / 2)
brand_start_y = 140 - int((abs(brand_height) + abs(slogan_height)) / 2) + abs(brand_height)
# print(brand_start_x)
brand_th.setTranslation(brand_start_x, brand_start_y)
brand_group.set_transform(brand_th.getTransform())
# bb = self.oh.createCircle(brand_start_x, brand_start_y, 2, fill='orange')
# 插入品牌语字体
for el in brand_elements:
brand_group.addElement(el)
# 标语计算位置坐标
slogan_start_x = 130 - int(slogan_width / 2)
slogan_start_y = brand_start_y
slogan_th.setTranslation(slogan_start_x, slogan_start_y)
slogan_group.set_transform(slogan_th.getTransform())
# ss = self.oh.createCircle(slogan_start_x, brand_start_y, 2, fill='white')
# 插入标语字体
for el in slogan_elements:
slogan_group.addElement(el)
# logo图样计算位置坐标
img_start_x = 90 + int((100 + max_length) / 2)
img_th.setTranslation(img_start_x, 90)
lo_rect = self.oh.createRect(0, 0, 100, 100, fill='yellow')
# logo_group.addElement(lo_rect)
logo_group.set_transform(img_th.getTransform())
if brand_location == '上':
# 品牌语计算位置坐标
brand_start_x = 190 - int(brand_width / 2)
brand_start_y = 140 - int((abs(brand_height) + abs(slogan_height)) / 2)
# print(brand_start_x)
brand_th.setTranslation(brand_start_x, brand_start_y)
brand_group.set_transform(brand_th.getTransform())
# bb = self.oh.createCircle(brand_start_x, brand_start_y, 2, fill='orange')
# 插入品牌语字体
for el in brand_elements:
brand_group.addElement(el)
# 标语计算位置坐标
slogan_start_x = 190 - int(slogan_width / 2)
slogan_start_y = brand_start_y
slogan_th.setTranslation(slogan_start_x, slogan_start_y)
slogan_group.set_transform(slogan_th.getTransform())
# ss = self.oh.createCircle(slogan_start_x, brand_start_y, 2, fill='white')
# 插入标语字体
for el in slogan_elements:
slogan_group.addElement(el)
# logo图样计算位置坐标
img_start_x = 140
img_th.setTranslation(img_start_x, brand_start_y+5)
lo_rect = self.oh.createRect(0, 0, 100, 100, fill='yellow')
# logo_group.addElement(lo_rect)
logo_group.set_transform(img_th.getTransform())
if brand_location == '下':
# 品牌语计算位置坐标
brand_start_x = 190 - int(brand_width / 2)
brand_start_y = 140 + int((abs(brand_height) + abs(slogan_height)) / 2)+ abs(brand_height) + abs(slogan_height)
# print(brand_start_x)
print(brand_start_x, brand_start_y)
brand_th.setTranslation(brand_start_x, brand_start_y)
brand_group.set_transform(brand_th.getTransform())
# bb = self.oh.createCircle(brand_start_x, brand_start_y, 2, fill='orange')
# 插入品牌语字体
for el in brand_elements:
brand_group.addElement(el)
# 标语计算位置坐标
slogan_start_x = 190 - int(slogan_width / 2)
slogan_start_y = brand_start_y
slogan_th.setTranslation(slogan_start_x, slogan_start_y)
slogan_group.set_transform(slogan_th.getTransform())
# ss = self.oh.createCircle(slogan_start_x, brand_start_y, 2, fill='white')
# 插入标语字体
for el in slogan_elements:
slogan_group.addElement(el)
# logo图样计算位置坐标
img_start_x = 140
img_start_y = brand_start_y - 100 - abs(brand_height) - abs(slogan_height)
img_th.setTranslation(img_start_x, img_start_y)
lo_rect = self.oh.createRect(0, 0, 100, 100, fill='yellow')
# logo_group.addElement(lo_rect)
logo_group.set_transform(img_th.getTransform())
svg_logo.addElement(brand_group)
svg_logo.addElement(slogan_group)
logo_group.addElement(logo_svg_read)
svg_logo.addElement(logo_group)
# center = self.oh.createCircle(190, 140, 2, fill='yellow')
# svg_logo.addElement(center)
# svg_logo.save('svg_log.svg', encoding='utf8')
return svg_logo
#创建svg图像,没有标语的存在
def create_svg_brand(self, brand_result,brand_coordinate, brand_color, brand_location, style_svg):
# 创建一个空白的svg
svg_logo = Svg(height="100%", width="100%")
# svg展示窗口大小
svg_logo.set_viewBox('0,0,380,280')
# 给窗口添加一个颜色,更直观
# bc_rect = self.oh.createRect(0, 0, 380, 280, fill='#FFFAE3')
# svg_logo.addElement(bc_rect)
# 创建品牌语风格
brand_style = StyleBuilder()
brand_style.setFilling(fill=brand_color)
# 遍历品牌语svg字体
brand_elements = []
for res in brand_result:
sub_group = G()
# sub_group.set_id(res['name'])
sub_group.set_style(brand_style.getStyle())
sub_path = Path(res['path_d'], style=brand_style.getStyle())
# sub_path.set_id('nn')
# sub_path.set_style(brandstyle.getStyle())
sub_group.addElement(sub_path)
brand_elements.append(sub_group)
# 品牌语的长度
brand_width = brand_coordinate[0]
brand_height = brand_coordinate[1]
# 对logo图像进行加载
logo_svg_read = parser.parse(style_svg)
logo_svg_read.set_width("100")
logo_svg_read.set_height("100")
# 定义品牌语图层
brand_group = G()
brand_th = TransformBuilder()
# 创建logo样式图层
logo_group = G()
img_th = TransformBuilder()
# 判断图样与文字的位置关系
if brand_location == '右':
# 品牌语计算位置坐标
brand_start_x = 230 - int(brand_width / 2)
brand_start_y = 140 -int(abs(brand_height)/ 2)+ abs(brand_height)
# print(brand_start_x)
brand_th.setTranslation(brand_start_x, brand_start_y)
brand_group.set_transform(brand_th.getTransform())
# bb = self.oh.createCircle(brand_start_x, brand_start_y, 2, fill='orange')
# 插入品牌语字体
for el in brand_elements:
brand_group.addElement(el)
# logo图样计算位置坐标
img_start_x = 190 - int((100 + brand_width) / 2)
img_th.setTranslation(img_start_x, 90)
# bc_rect = self.oh.createRect(0, 0, 100, 100, fill='yellow')
# logo_group.addElement(bc_rect)
logo_group.set_transform(img_th.getTransform())
if brand_location == '左':
# 品牌语计算位置坐标
brand_start_x = 140 - int(brand_width / 2)
brand_start_y = 140 - int(abs(brand_height) / 2) + abs(brand_height)
# print(brand_start_x)
brand_th.setTranslation(brand_start_x, brand_start_y)
brand_group.set_transform(brand_th.getTransform())
# bb = self.oh.createCircle(brand_start_x, brand_start_y, 2, fill='orange')
# 插入品牌语字体
for el in brand_elements:
brand_group.addElement(el)
# logo图样计算位置坐标
img_start_x = 90 + int((100 + brand_width) / 2)
img_th.setTranslation(img_start_x, 90)
# lo_rect = self.oh.createRect(0, 0, 100, 100, fill='yellow')
# logo_group.addElement(lo_rect)
logo_group.set_transform(img_th.getTransform())
if brand_location == '上':
# 品牌语计算位置坐标
brand_start_x = 190 - int(brand_width / 2)
brand_start_y = 140 - int(abs(brand_height) / 2)
# print(brand_start_x)
brand_th.setTranslation(brand_start_x, brand_start_y)
brand_group.set_transform(brand_th.getTransform())
# bb = self.oh.createCircle(brand_start_x, brand_start_y, 2, fill='orange')
# 插入品牌语字体
for el in brand_elements:
brand_group.addElement(el)
# logo图样计算位置坐标
img_start_x = 140
img_th.setTranslation(img_start_x, brand_start_y)
# lo_rect = self.oh.createRect(0, 0, 100, 100, fill='yellow')
# logo_group.addElement(lo_rect)
logo_group.set_transform(img_th.getTransform())
if brand_location == '下':
# 品牌语计算位置坐标
brand_start_x = 190 - int(brand_width / 2)
brand_start_y = 140 + int(abs(brand_height) / 2) + abs(brand_height)
# print(brand_start_x)
brand_th.setTranslation(brand_start_x, brand_start_y)
brand_group.set_transform(brand_th.getTransform())
bb = self.oh.createCircle(brand_start_x, brand_start_y, 2, fill='orange')
# 插入品牌语字体
for el in brand_elements:
brand_group.addElement(el)
# logo图样计算位置坐标
img_start_x = 140
img_start_y = brand_start_y - 100 - abs(brand_height)
img_th.setTranslation(img_start_x, img_start_y)
# lo_rect = self.oh.createRect(0, 0, 100, 100, fill='yellow')
# logo_group.addElement(lo_rect)
logo_group.set_transform(img_th.getTransform())
svg_logo.addElement(brand_group)
logo_group.addElement(logo_svg_read)
svg_logo.addElement(logo_group)
# center = self.oh.createCircle(190, 140, 2, fill='yellow')
# svg_logo.addElement(center)
# svg_logo.save('svg_log.svg', encoding='utf8')
return svg_logo
# 首先对字符找到对应的ASCII数值,然后去字体库里找到对应字符的unicode编码
@classmethod # 用到类的修饰符,表示不需要进行实例化
def get_unicode(cls, font_path, text):
textlist = []
for ch in text:
ch_ascii = ord(ch)
textlist.append({'name': ch, 'ucode': ch_ascii})
# 读取字体库
font_lib = TTFont(font_path)
cmap = font_lib['cmap']
for ucode, gname in cmap.getBestCmap().items():
for tl in textlist:
if ucode == tl['ucode']:
tl['unicode'] = gname
return textlist
#RGB格式的颜色值转化为16进制
@classmethod
def rgb_to_hex(cls,rgb):
color = '#'
rgblist = list(rgb)
for i in rgblist:
num = int(i)
# 将R、G、B分别转化为16进制拼接转换并大写 hex() 函数用于将10进制整数转换成16进制,以字符串形式表示
color += str(hex(num))[-2:].replace('x', '0').upper()
# print(color)
return color
# 16进制颜色格式颜色转换为RGB格式
@classmethod
def Hex_to_RGB(hex):
r = int(hex[1:3], 16)
g = int(hex[3:5], 16)
b = int(hex[5:7], 16)
rgb = str(r) + ',' + str(g) + ',' + str(b)
# print(rgb)
return rgb
#打包程序入口
......@@ -206,12 +557,12 @@ def gen_main(gen_json):
# 图标下载
logo_url = gen_json['logo_url']
# logo名字
logo_name = time.strftime('%Y%m%d%H%M%S') + '.png'
logo_name = time.strftime('%Y%m%d%H%M%S') + str(random.randint(100, 10000)) + '.png'
logo_down_path = 'logodir/' + logo_name
# 本地下载logo样式方法
logo_down_result = downlogo(logo_down_path, logo_url)
# 线上读取logo样式方法
#logo_down_result = downlogo_path(logo_down_path, logo_url)
# logo_down_result = downlogo_path(logo_down_path, logo_url)
# 定义生成的图像接受对象
if logo_down_result:
# 判断标语是否存在
......@@ -234,43 +585,90 @@ def gen_main(gen_json):
slogan_size = 60
slogan_font = ImageFont.truetype('font/cn/微软vista雅黑.ttf', slogan_size)
slogan_font_alpha = ImageFont.truetype('font/cn/微软vista雅黑.ttf', slogan_size)
#创建存放生成该品牌语的路径
brand_path = 'downlogo/'+brand_text+'/高清Logo'
# 创建存放生成该品牌语的路径
brand_path = 'downlogo/' + brand_text + '/高清Logo'
if not os.path.exists(brand_path):
os.makedirs(brand_path)
# 白底黑字
white_bottom_black_text = lg_gen.generator_base('RGBA',brand_text, brand_font, (0,0,0), brand_location, slogan_text,
slogan_font,(0, 0, 0), alpha2white(logo_img),(255,255,255))
white_bottom_black_text = lg_gen.generator_base('RGBA', brand_text, brand_font, (0, 0, 0), brand_location,
slogan_text,
slogan_font, (0, 0, 0), alpha2white(logo_img),
(255, 255, 255))
# 黑底白字
black_bottom_white_text = lg_gen.generator_base('RGB',brand_text, brand_font, (255, 255, 255), brand_location, slogan_text,
slogan_font, (255, 255, 255), logo_img, (0, 0, 0))
black_bottom_white_text = lg_gen.generator_base('RGB', brand_text, brand_font, (255, 255, 255),
brand_location, slogan_text,
slogan_font, (255, 255, 255), logo_img, (0, 0, 0))
# 白底原色字
white_bottom_color_text = lg_gen.generator_base('RGBA',brand_text, brand_font, brand_color, brand_location, slogan_text,
slogan_font, slogan_color, alpha2white(logo_img), (255, 255, 255))
white_bottom_color_text = lg_gen.generator_base('RGBA', brand_text, brand_font, brand_color, brand_location,
slogan_text,
slogan_font, slogan_color, alpha2white(logo_img),
(255, 255, 255))
# 黑底原色字
black_bottom_color_text = lg_gen.generator_base('RGB',brand_text, brand_font, brand_color, brand_location,
slogan_text,slogan_font, slogan_color, logo_img, (0, 0, 0))
black_bottom_color_text = lg_gen.generator_base('RGB', brand_text, brand_font, brand_color, brand_location,
slogan_text, slogan_font, slogan_color, logo_img, (0, 0, 0))
# 透明底白色字
alpha_bottom_white_text = lg_gen.generator_base_alpha(brand_text, brand_font_alpha, (255,255,255), brand_location,
slogan_text,slogan_font_alpha, (255,255,255), logo_img)
alpha_bottom_white_text = lg_gen.generator_base_alpha(brand_text, brand_font_alpha, (255, 255, 255),
brand_location,
slogan_text, slogan_font_alpha, (255, 255, 255),
logo_img)
# 透明底黑色字
alpha_bottom_black_text = lg_gen.generator_base_alpha(brand_text, brand_font_alpha, (0,0,0), brand_location,
slogan_text,slogan_font_alpha, (0,0,0), logo_img)
alpha_bottom_black_text = lg_gen.generator_base_alpha(brand_text, brand_font_alpha, (0, 0, 0),
brand_location,
slogan_text, slogan_font_alpha, (0, 0, 0), logo_img)
# 透明底原色字
alpha_bottom_color_text = lg_gen.generator_base_alpha(brand_text, brand_font_alpha, brand_color, brand_location,
slogan_text,slogan_font_alpha, slogan_color, logo_img)
alpha_bottom_color_text = lg_gen.generator_base_alpha(brand_text, brand_font_alpha, brand_color,
brand_location,
slogan_text, slogan_font_alpha, slogan_color,
logo_img)
# ----------生成svg图像的方法
if gen_json['svg_url']:
svg_name = time.strftime('%Y%m%d%H%M%S') + str(random.randint(100, 10000)) + '.svg'
svg_down_path = 'logodir/' + svg_name
# 本地下载logo样式方法
svg_down_result = downlogo(svg_down_path, gen_json['svg_url'])
#保存生成的各种图像
white_bottom_black_text_path = brand_path+'/'+'白底黑字.png' #白底黑字
black_bottom_white_text_path = brand_path+'/'+'黑底白字.png' #黑底白字
white_bottom_color_text_path = brand_path+'/'+'白底原色字.png' #白底原色字
black_bottom_color_text_path = brand_path+'/'+'黑底原色字.png' #黑底原色字
alpha_bottom_white_text_path = brand_path+'/'+'透明底白色字.png' # 透明底白色字
alpha_bottom_black_text_path = brand_path+'/'+'透明底黑色字.png' # 透明底黑色字
alpha_bottom_color_text_path = brand_path+'/'+'透明底原色字.png' # 透明底原色字
if svg_down_result:
# brand_font_path = 'font/cn/华文中宋.ttf'
brand_font_path = gen_json["brand_font"]
slogan_font_path = 'font/cn/微软vista雅黑.ttf'
brand_text_list = generatorSvg.get_unicode(brand_font_path, brand_text)
brand_result, brand_coordinate = brandFont(brand_font_path, brand_text_list)
# brand_location = '下'
brand_color = generatorSvg.rgb_to_hex(brand_color)
slogan_color = generatorSvg.rgb_to_hex(slogan_color)
# style_svg = 'svgtest/svgdata/3.svg'
style_svg = svg_down_result
if slogan_text == '':
# 生成svg
svg_gen = generatorSvg()
svg_img = svg_gen.create_svg_brand(brand_result, brand_coordinate, brand_color, brand_location,
style_svg)
else:
slogan_text_list = generatorSvg.get_unicode(slogan_font_path, slogan_text)
slogan_result, slogan_coordinate = sloganFont(slogan_font_path, slogan_text_list)
# print(slogan_result)
# 生成svg
svg_gen = generatorSvg()
svg_img = svg_gen.create_svg_brand_slogan(brand_result, brand_coordinate, brand_color,
brand_location,
slogan_result, slogan_coordinate, slogan_color,
style_svg)
# brand_svg_path = 'downlogo/' + brand_text + '/'
brand_svg_path = 'downlogo/' + brand_text + '/' + brand_text + '.svg'
svg_img.save(brand_svg_path, encoding='utf8')
# 保存生成的各种图像
white_bottom_black_text_path = brand_path + '/' + '白底黑字.png' # 白底黑字
black_bottom_white_text_path = brand_path + '/' + '黑底白字.png' # 黑底白字
white_bottom_color_text_path = brand_path + '/' + '白底原色字.png' # 白底原色字
black_bottom_color_text_path = brand_path + '/' + '黑底原色字.png' # 黑底原色字
alpha_bottom_white_text_path = brand_path + '/' + '透明底白色字.png' # 透明底白色字
alpha_bottom_black_text_path = brand_path + '/' + '透明底黑色字.png' # 透明底黑色字
alpha_bottom_color_text_path = brand_path + '/' + '透明底原色字.png' # 透明底原色字
white_bottom_black_text.save(white_bottom_black_text_path)
black_bottom_white_text.save(black_bottom_white_text_path)
......@@ -279,31 +677,32 @@ def gen_main(gen_json):
alpha_bottom_white_text.save(alpha_bottom_white_text_path)
alpha_bottom_black_text.save(alpha_bottom_black_text_path)
alpha_bottom_color_text.save(alpha_bottom_color_text_path)
#创建说明文档
with open('downlogo/'+brand_text+'/使用说明.txt','w') as ff:
# 创建说明文档
with open('downlogo/' + brand_text + '/使用说明.txt', 'w') as ff:
context1 = '-----------------文件附录-----------------\n'
context2 = '高清Logo图,包含七种png图像\n'
context3 = '矢量源文件\n'
ff.write(context1)
ff.write(context2)
ff.write(context3)
zip_path,zip_name = make_zip(brand_text)
zip_path, zip_name = make_zip(brand_text)
#将压缩包上传到阿里云oss上
down_url = put2oss(zip_name,zip_path)
# 将压缩包上传到阿里云oss上
down_url = put2oss(zip_name, zip_path)
# print(down_url)
return {
'status': 1,
'down_url': down_url,
'msg':'success'
'msg': 'success'
}
else:
return {
'status': 0,
'down_url': '',
'msg':'下载图标失败!'
'msg': '下载图标失败!'
}
except Exception as e:
print(e)
return {
......
......@@ -9,19 +9,37 @@ import os
import time
import shutil
from threading import Thread
import LogoParseFonts
#随机取50个descid,其中15个模板id,35个logoid
def GetDescId(sptagdata,templatedata):
returnlist = []
if len(templatedata) <= 15:
returnlist.extend(templatedata)
else:
returnlist.extend(random.sample(templatedata,15))
if len(sptagdata) <= (50- len(returnlist)):
returnlist.extend(sptagdata)
else:
returnlist.extend(random.sample(sptagdata, 50- len(returnlist)))
return returnlist
try:
returnlist = []
dis_list = []
for sptag in sptagdata:
if sptag["distance"] not in dis_list:
dis_list.append(sptag["distance"])
for template in templatedata:
if template["distance"] not in dis_list:
dis_list.append(template["distance"])
# 排序
dis_list.sort(reverse=False)
for dis in dis_list:
for sptag in sptagdata:
if sptag["distance"] == dis:
returnlist.append(sptag)
for template in templatedata:
if template["distance"] == dis:
returnlist.append(template)
# 最多取50个
if len(returnlist) <= 50:
return returnlist
else:
return returnlist[0:50]
except:
return []
#多线程处理生成logo
def wgetlogo(logourl,logoinfo):
......@@ -57,32 +75,39 @@ def SaveLogoResource(inputdata,msg_id,cur):
data1 = {"input_text":text } # 接口访问参数
# params = json.dumps(data, ensure_ascii=False)
sptagdata = []
dis_set = set()
try:
sptagdata1 = requests.post(sptagapi, json=data1).json() # 得到logoid
sptagdata1 = requests.post(sptagapi, json=data1).json() # 得到logoid和相似度系数
# 过滤行业
idlist = []
for idinfo in sptagdata1:
idlist.append(idinfo["id"])
select_sql = "select * from logo_desc where id = %s" % idinfo["id"]
cur.execute(select_sql)
msg = cur.fetchone()
if msg["profession"] == inputdata["profession"]:
sptagdata.append({"id": msg["id"]})
except:#若语义分析出错,随机取50个
select_sql = 'SELECT id FROM `logo_desc` WHERE type = "standard" and mark = 0 and profession = %s and id >= ( SELECT floor(RAND() ' \
# print(str(msg))
if msg and msg["profession"] == inputdata["profession"]:
sptagdata.append({"id": idinfo["id"], "distance": idinfo["distance"]})
dis_set.add(idinfo["distance"])
except Exception as e2: # 若语义分析出错,随机取50个
dis_set.clear()
sptagdata.clear()
select_sql = 'SELECT id FROM `logo_desc` WHERE type = "standard" and mark = 0 and profession = "%s" and id >= ( SELECT floor(RAND() ' \
'* (SELECT MAX(id) FROM `logo_desc`))) ORDER BY id LIMIT 50' % inputdata["profession"]
cur.execute(select_sql)
msgs = cur.fetchall()
for ms in msgs:
sptagdata.append({"id": ms["id"]})
distance = round(random.uniform(-20, -10), 5)
sptagdata.append({"id": ms["id"], "distance": distance})
dis_set.add(distance)
#sptagdata = [{"id":"1"},{"id":"2"},{"id":"3"}]
#取模板id
templatedata = []
dis_max = max(dis_set)
dis_min = min(dis_set)
select_sql = 'select id from logo_desc where type = "template" '
cur.execute(select_sql)
msgs = cur.fetchall()
for ms in msgs:
templatedata.append({"id":ms["id"]})
templatedata.append({"id":ms["id"],"distance":round(random.uniform(dis_min, dis_max),5)})
#取30条语义分析结果都是logo的,再随机20条模板
descList = GetDescId(sptagdata,templatedata)
for data in descList:
......@@ -91,7 +116,7 @@ def SaveLogoResource(inputdata,msg_id,cur):
cur.execute(select_sql)
msg=cur.fetchone()
insert_sql='insert into logo_res (logo_id,first_color,sec_color,height,width,profession,description,textpos,' \
'originality,type,msg_id) VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)'
'originality,coefficient,type,msg_id) VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)'
logo_id = msg["id"]
first_color = msg["first_color"]
......@@ -101,11 +126,12 @@ def SaveLogoResource(inputdata,msg_id,cur):
profession = msg["profession"]
description = msg["description"]
originality = msg["originality"]
coefficient = data["distance"]
textpos = msg["textpos"]
type = msg["type"]
#msg_id = msg_id
tup = (logo_id, first_color, sec_color, height, width, profession, description,textpos,originality,
type,msg_id)
coefficient,type,msg_id)
#print(str(tup))
cur.execute(insert_sql, tup)
#connection.commit()
......@@ -178,21 +204,17 @@ def ChangeABatch(inputdata):
res_list = []
if data and data["isasy"]:#说明已做过生成
mgs_id = data["id"]
select_sql = "select * from logo_res where msg_id = %s and (pic_url is null or pic_url = '') " % mgs_id
select_sql = "select * from logo_res where msg_id = %s and (pic_url is null or pic_url = '') order by coefficient DESC LIMIT 10" % mgs_id
cur.execute(select_sql)
data = cur.fetchall()
if data:#如果存在未生成图片的
len1 = 10
if len(data) < 10:
len1 = len(data)
random_list = random.sample(data, len1)
for dl in random_list:
if data: # 如果存在未生成图片的
for dl in data:
dict1 = {
"id": dl["id"],
"logo_id": dl["logo_id"],
"font_id": dl["font_id"],
"title":inputdata["title"],
"subtitle":inputdata["subtitle"],
"title": inputdata["title"],
"subtitle": inputdata["subtitle"],
"first_color": dl["first_color"],
"sec_color": dl["sec_color"],
"textpos": dl["textpos"],
......@@ -252,16 +274,32 @@ def ChangeABatch(inputdata):
res["color_description"] = ""
#随机一个字体
randnum = random.randint(0, len(fontlist) - 1)
font_url = fontlist[randnum]["fonts_url"]
font_id = fontlist[randnum]["id"]
font_name = fontlist[randnum]["font_name"]
font_dec = fontlist[randnum]["font_description"]
isfont = False # 判断一次输入的字体是否在字体文件中都存在
randnum = 0
t_font_list = fontlist
while not isfont:
randnum = random.randint(0, len(t_font_list) - 1)
isfont = LogoParseFonts.get_unicode(t_font_list[randnum]["fonts_url"], inputdata["title"])
if not isfont:
t_font_list.remove(t_font_list[randnum])
if len(t_font_list) ==0:
break
if len(t_font_list) ==0:
font_url = fontlist[randnum]["fonts_url"]
font_id = fontlist[randnum]["id"]
font_name = fontlist[randnum]["font_name"]
font_dec = fontlist[randnum]["font_description"]
else:
font_url = t_font_list[randnum]["fonts_url"]
font_id = t_font_list[randnum]["id"]
font_name = t_font_list[randnum]["font_name"]
font_dec = t_font_list[randnum]["font_description"]
res["font_id"] = font_id
res["font_url"] = font_url
res["font_name"] = font_name
res["font_description"] = font_dec
if not res["pic_url"]:
#k = MyThread(wgetlogo, args=('http://127.0.0.1:5000/api/createlogo',res))
k = MyThread(wgetlogo, args=('http://createlogo-service/api/createlogo',res))
k.start()
threadlist.append(k)
......@@ -348,14 +386,14 @@ def ReturnLogoInfo(inputdata,curpage,pagesize):
#根据id取语义分析的结果
select_sql = 'select * from logo_res where msg_id = "%s"' % msg_id
select_sql = 'select * from logo_res where msg_id = "%s" order by coefficient DESC' % msg_id
#cur = connection.cursor(cursor=pymysql.cursors.DictCursor)
cur.execute(select_sql)
res_list = cur.fetchall()
re_count = 30
if len(res_list) <30:
re_count = len(res_list)
random_list = random.sample(res_list, re_count)
random_list = res_list[0:re_count]
#取所有字体
fontlist = []
......@@ -402,11 +440,26 @@ def ReturnLogoInfo(inputdata,curpage,pagesize):
dict1["log_url"] = ""
dict1["color_description"] = ""
# 随机一个字体
randnum = random.randint(0, len(fontlist) - 1)
font_url = fontlist[randnum]["fonts_url"]
font_id = fontlist[randnum]["id"]
font_name = fontlist[randnum]["font_name"]
font_dec = fontlist[randnum]["font_description"]
isfont = False # 判断一次输入的字体是否在字体文件中都存在
randnum = 0
t_font_list = fontlist
while not isfont:
randnum = random.randint(0, len(t_font_list) - 1)
isfont = LogoParseFonts.get_unicode(t_font_list[randnum]["fonts_url"], inputdata["title"])
if not isfont:
t_font_list.remove(t_font_list[randnum])
if len(t_font_list) == 0:
break
if len(t_font_list) == 0:
font_url = fontlist[randnum]["fonts_url"]
font_id = fontlist[randnum]["id"]
font_name = fontlist[randnum]["font_name"]
font_dec = fontlist[randnum]["font_description"]
else:
font_url = t_font_list[randnum]["fonts_url"]
font_id = t_font_list[randnum]["id"]
font_name = t_font_list[randnum]["font_name"]
font_dec = t_font_list[randnum]["font_description"]
dict1["font_id"] = font_id
dict1["font_url"] = font_url #
dict1["font_name"] = font_name
......@@ -428,6 +481,7 @@ def ReturnLogoInfo(inputdata,curpage,pagesize):
for r in list_r:
if not r["pic_url"]:
k = MyThread(wgetlogo, args=('http://createlogo-service/api/createlogo', r))
#k = MyThread(wgetlogo, args=('http://127.0.0.1:5000/api/createlogo', r))
k.start()
threadlist.append(k)
else:
......@@ -467,7 +521,7 @@ def ReturnLogoInfo(inputdata,curpage,pagesize):
#删除临时文件
def Deletefile():
try:
dirlist = ["data", "downlogo", "generatordir", "logodir"]
dirlist = ["downlogo", "generatordir", "logodir"]
for dir in dirlist:
for root, dirs, files in os.walk(dir):
for name in files:
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2020-05-18 14:04
# @Author : zhangyunfei
# @File : LogoParseFonts.py
# @Software: PyCharm
from fontTools.ttLib import TTFont
# 首先对字符找到对应的ASCII数值,然后去字体库里找到对应字符的unicode编码
def get_unicode(font_path, text):
try:
textlist = []
for ch in text:
ch_ascii = ord(ch)
textlist.append({'name': ch, 'ucode': ch_ascii})
# 读取字体库
font_lib = TTFont(font_path)
cmap = font_lib['cmap']
for ucode, gname in cmap.getBestCmap().items():
for tl in textlist:
if ucode == tl['ucode']:
tl['unicode'] = gname
text_count = 0
text_unicode_count = 0
for item in textlist:
if item.get('name'):
text_count += 1
if item.get('unicode') is not None:
text_unicode_count += 1
if text_count == text_unicode_count:
return True
else:
return False
except:
return False
# if __name__ == '__main__':
# brand_text = '我爱我家'
# brand_font_path = 'font/cn/白舟·侍.ttf'
# # brand_font_path = 'font/cn/华文隶书.TTF'
# brand_text_list = get_unicode(brand_font_path, brand_text)
#
# print(brand_text_list)
\ No newline at end of file
......@@ -222,6 +222,6 @@ def DeletefileApi():#删除临时文件
if __name__ == '__main__':
CORS(app, supports_credentials=True)#允许跨域
app.run(host='0.0.0.0', port=80, debug=True)
#app.run(host='127.0.0.1', port=5000, debug=True)
# app.run(host='0.0.0.0', port=80, debug=True)
app.run(host='127.0.0.1', port=5000, debug=True)
#!/usr/bin/env python
# Copyright 2016 Adobe. All rights reserved.
"""
Generates a set of SVG glyph files from one or more fonts and hex colors
for each of them. The fonts' format can be either OpenType, TrueType, WOFF,
or WOFF2.
"""
import os
import re
import sys
import time
import requests
from io import BytesIO
import json
#import util.check_fonttools # pylint: disable=unused-import
from fontTools import ttLib
from fontTools.pens.basePen import BasePen
from fontTools.pens.transformPen import TransformPen
class SVGPen(BasePen):
def __init__(self, glyphSet):
BasePen.__init__(self, glyphSet)
self.d = u''
self._lastX = self._lastY = None
self.xList = []
def _moveTo(self, pt):
self.xList.append(pt)
ptx, pty = self._isInt(pt)
self.d += u'M{} {}'.format(ptx, pty)
self._lastX, self._lastY = pt
def _lineTo(self, pt):
self.xList.append(pt)
ptx, pty = self._isInt(pt)
if (ptx, pty) == (self._lastX, self._lastY):
return
elif ptx == self._lastX:
self.d += u'V{}'.format(pty)
elif pty == self._lastY:
self.d += u'H{}'.format(ptx)
else:
self.d += u'L{} {}'.format(ptx, pty)
self._lastX, self._lastY = pt
def _curveToOne(self, pt1, pt2, pt3):
self.xList.append(pt1)
self.xList.append(pt2)
self.xList.append(pt3)
pt1x, pt1y = self._isInt(pt1)
pt2x, pt2y = self._isInt(pt2)
pt3x, pt3y = self._isInt(pt3)
self.d += u'C{} {} {} {} {} {}'.format(pt1x, pt1y, pt2x, pt2y,
pt3x, pt3y)
self._lastX, self._lastY = pt3
def _qCurveToOne(self, pt1, pt2):
self.xList.append(pt1)
self.xList.append(pt2)
pt1x, pt1y = self._isInt(pt1)
pt2x, pt2y = self._isInt(pt2)
self.d += u'Q{} {} {} {}'.format(pt1x, pt1y, pt2x, pt2y)
self._lastX, self._lastY = pt2
def _closePath(self):
self.d += u'Z'
self._lastX = self._lastY = None
def _endPath(self):
self._closePath()
@staticmethod
def _isInt(tup):
return [int(flt) if (flt).is_integer() else flt for flt in tup]
def processFonts(font_path):
# Load the fonts and collect their glyph sets
font = ttLib.TTFont(font_path)
print(font)
gSet = font.getGlyphSet()
print(gSet)
glyphNamesList = gSet.keys()
print(glyphNamesList)
font.close()
# Confirm that there's something to process
if not glyphNamesList:
print("The fonts and options provided can't produce any SVG files.",
file=sys.stdout)
return
web_font_dict = dict()
glyphNamesList1 =['uniFF54','uniFF55','uniFF56']
# Generate the SVGs
for gName in glyphNamesList1:
pen = SVGPen(gSet)
tpen = TransformPen(pen, (0.035, 0.0, 0.0, -0.035, -20.0, 0.0))
glyph = gSet[gName]
glyph.draw(tpen)
d = pen.d
# print(gName)
# print(d)
# Skip glyphs with no contours
if not len(d):
continue
web_font_dict[gName] = d # (gname, d)
# print(web_font_dict)
font.close()
return web_font_dict
#品牌语生成字体
def brandFont(font_path,ucodelist):
# Load the fonts and collect their glyph sets
font = ttLib.TTFont(font_path)
gSet = font.getGlyphSet()
glyphNamesList = gSet.keys()
# Confirm that there's something to process
if not glyphNamesList:
print("The fonts and options provided can't produce any SVG files.",
file=sys.stdout)
return
web_font_list = []
x = 0
boxlist = []
for gName in ucodelist:
# print(gName,'+++++++++++++++++++++++++++++++++++++++++++++')
pen = SVGPen(gSet)
tpen = TransformPen(pen, (0.028, 0.0, 0.0, -0.028, x*28.0, -8.0))
name = gName['name']
glyph = gSet[gName['unicode']]
glyph.draw(tpen)
d = pen.d
boxlist.extend(pen.xList)
# print(gName)
# print(d)
# Skip glyphs with no contours
if not len(d):
continue
web_font_list.append({'name':name,'path_d':d}) # (gname, d)
x+=1
font.close()
# print(web_font_list)
xx = []
yy = []
for it in boxlist:
xx.append(it[0])
yy.append(it[1])
righttop_x = int(max(xx))
righttop_y = int(min(yy))
righttop = (righttop_x,righttop_y)
return web_font_list,righttop
#标语生成字体
def sloganFont(font_path,ucodelist):
font = ttLib.TTFont(font_path)
gSet = font.getGlyphSet()
glyphNamesList = gSet.keys()
# Confirm that there's something to process
if not glyphNamesList:
print("The fonts and options provided can't produce any SVG files.",
file=sys.stdout)
return
web_font_list = []
x = 0
boxlist = []
for gName in ucodelist:
# print(gName, '+++++++++++++++++++++++++++++++++++++++++++++')
pen = SVGPen(gSet)
tpen = TransformPen(pen, (0.0035, 0.0, 0.0, -0.0035, x * 8.0, 6.0))
name = gName['name']
glyph = gSet[gName['unicode']]
glyph.draw(tpen)
d = pen.d
boxlist.extend(pen.xList)
# print(gName)
# print(d)
# Skip glyphs with no contours
if not len(d):
continue
web_font_list.append({'name':name,'path_d':d}) # (gname, d)
x += 1
font.close()
xx = []
yy = []
for it in boxlist:
xx.append(it[0])
yy.append(it[1])
righttop_x = int(max(xx))
righttop_y = int(max(yy))
righttop = (righttop_x, righttop_y)
return web_font_list, righttop
# if __name__ == "__main__":
# start = time.time()
# lt = [{'name': '粒', 'ucode': 31890, 'unicode': 'uni7C92'}, {'name': '子', 'ucode': 23376, 'unicode': 'uni5B50'}, {'name': '风', 'ucode': 39118, 'unicode': 'uni98CE'}, {'name': '暴', 'ucode': 26292, 'unicode': 'uni66B4'}]
# lt2 = [{'name': '厘', 'ucode': 21400, 'unicode': 'uni5398'}, {'name': '山', 'ucode': 23665, 'unicode': 'uni5C71'}, {'name': '科', 'ucode': 31185, 'unicode': 'uni79D1'}, {'name': '技', 'ucode': 25216, 'unicode': 'uni6280'}]
#
# results = brandFont('../font/cn/hwfs.ttf',lt2)
# print('time cost is: ', time.time() - start)
# print(results)
# '''
# headers = {
# 'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36"
# }
# response = requests.get(url="https://" + 's3plus.meituan.net/v1/mss_73a511b8f91f43d0bdae92584ea6330b/font/53cfe63b.woff', headers=headers)
# woff_file = BytesIO()
# for chunk in response.iter_content(100000):
# woff_file.write(chunk)
# results = font2svg(woff_file)
# print(results)
# '''
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment