remove last remnants of rotate instead of transform, updated rot* svgs to have arrow point in direction of actual rotation, AND, fixed bug where when we rotate an image that has already had an exif_transform on it, then we have to do that and then the requested rotation - fixes why sometimes we rotate say 180 when we intended a 90 rotate. Also, when we transform, recalc md5 as file has changed
This commit is contained in:
@@ -157,18 +157,6 @@
|
|||||||
c4.142,0,7.5-3.357,7.5-7.5S339.642,328,335.5,328z"/>
|
c4.142,0,7.5-3.357,7.5-7.5S339.642,328,335.5,328z"/>
|
||||||
<g style="fill:#00000025;" transform="matrix(16, 0, 0, 16, 120, 115)"><path d="M4.502 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3z"/><path d="M14.002 13a2 2 0 0 1-2 2h-10a2 2 0 0 1-2-2V5A2 2 0 0 1 2 3a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v8a2 2 0 0 1-1.998 2zM14 2H4a1 1 0 0 0-1 1h9.002a2 2 0 0 1 2 2v7A1 1 0 0 0 15 11V3a1 1 0 0 0-1-1zM2.002 4a1 1 0 0 0-1 1v8l2.646-2.354a.5.5 0 0 1 .63-.062l2.66 1.773 3.71-3.71a.5.5 0 0 1 .577-.094l1.777 1.947V5a1 1 0 0 0-1-1h-10z"/></g>
|
<g style="fill:#00000025;" transform="matrix(16, 0, 0, 16, 120, 115)"><path d="M4.502 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3z"/><path d="M14.002 13a2 2 0 0 1-2 2h-10a2 2 0 0 1-2-2V5A2 2 0 0 1 2 3a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v8a2 2 0 0 1-1.998 2zM14 2H4a1 1 0 0 0-1 1h9.002a2 2 0 0 1 2 2v7A1 1 0 0 0 15 11V3a1 1 0 0 0-1-1zM2.002 4a1 1 0 0 0-1 1v8l2.646-2.354a.5.5 0 0 1 .63-.062l2.66 1.773 3.71-3.71a.5.5 0 0 1 .577-.094l1.777 1.947V5a1 1 0 0 0-1-1h-10z"/></g>
|
||||||
</svg>
|
</svg>
|
||||||
<svg id="rot90" fill="currentColor" viewBox="0 0 16 16">
|
|
||||||
<path d="M1.161,8a6.84,6.84,0,1,0,6.842,-6.84a0.58,0.58,0,1,1,0,-1.16a8,8,0,1,1,-6.556,3.412l-0.663,-0.577a0.58,0.58,0,0,1,0.227,-0.997l2.52,-0.69a0.58,0.58,0,0,1,0.728,0.633l-0.332,2.592a0.58,0.58,0,0,1,-0.956,0.364l-0.643,-0.56a6.812,6.812,0,0,0,-1.168,3.823Z"/>
|
|
||||||
<text style="font-family: Arial; font-size: 8px;" x="3.71597" y="10.935">90</text>
|
|
||||||
</svg>
|
|
||||||
<svg id="rot180" fill="currentColor" viewBox="0 0 16 16">
|
|
||||||
<path d="M1.161,8a6.84,6.84,0,1,0,6.842,-6.84a0.58,0.58,0,1,1,0,-1.16a8,8,0,1,1,-6.556,3.412l-0.663,-0.577a0.58,0.58,0,0,1,0.227,-0.997l2.52,-0.69a0.58,0.58,0,0,1,0.728,0.633l-0.332,2.592a0.58,0.58,0,0,1,-0.956,0.364l-0.643,-0.56a6.812,6.812,0,0,0,-1.168,3.823Z"/>
|
|
||||||
<text style="font-family: Arial; font-size: 8px;" x="0.875727" y="10.935">180</text>
|
|
||||||
</svg>
|
|
||||||
<svg id="rot270" fill="currentColor" viewBox="0 0 16 16">
|
|
||||||
<path d="M1.161,8a6.84,6.84,0,1,0,6.842,-6.84a0.58,0.58,0,1,1,0,-1.16a8,8,0,1,1,-6.556,3.412l-0.663,-0.577a0.58,0.58,0,0,1,0.227,-0.997l2.52,-0.69a0.58,0.58,0,0,1,0.728,0.633l-0.332,2.592a0.58,0.58,0,0,1,-0.956,0.364l-0.643,-0.56a6.812,6.812,0,0,0,-1.168,3.823Z"/>
|
|
||||||
<text style="font-family: Arial; font-size: 8px;" x="1.63312" y="10.935">270</text>
|
|
||||||
</svg>
|
|
||||||
<svg id="flip_h" fill="currentColor" viewBox='0 0 512 512'>
|
<svg id="flip_h" fill="currentColor" viewBox='0 0 512 512'>
|
||||||
<path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='32' d='M304 48l112 112-112 112M398.87 160H96M208 464L96 352l112-112M114 352h302'/>
|
<path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='32' d='M304 48l112 112-112 112M398.87 160H96M208 464L96 352l112-112M114 352h302'/>
|
||||||
</svg>
|
</svg>
|
||||||
@@ -181,4 +169,25 @@
|
|||||||
<svg id="unknown_ftype" fill="grey" viewBox="0 0 16 16">
|
<svg id="unknown_ftype" fill="grey" viewBox="0 0 16 16">
|
||||||
<path d="M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm3.496 6.033a.237.237 0 0 1-.24-.247C5.35 4.091 6.737 3.5 8.005 3.5c1.396 0 2.672.73 2.672 2.24 0 1.08-.635 1.594-1.244 2.057-.737.559-1.01.768-1.01 1.486v.105a.25.25 0 0 1-.25.25h-.81a.25.25 0 0 1-.25-.246l-.004-.217c-.038-.927.495-1.498 1.168-1.987.59-.444.965-.736.965-1.371 0-.825-.628-1.168-1.314-1.168-.803 0-1.253.478-1.342 1.134-.018.137-.128.25-.266.25h-.825zm2.325 6.443c-.584 0-1.009-.394-1.009-.927 0-.552.425-.94 1.01-.94.609 0 1.028.388 1.028.94 0 .533-.42.927-1.029.927z"/>
|
<path d="M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm3.496 6.033a.237.237 0 0 1-.24-.247C5.35 4.091 6.737 3.5 8.005 3.5c1.396 0 2.672.73 2.672 2.24 0 1.08-.635 1.594-1.244 2.057-.737.559-1.01.768-1.01 1.486v.105a.25.25 0 0 1-.25.25h-.81a.25.25 0 0 1-.25-.246l-.004-.217c-.038-.927.495-1.498 1.168-1.987.59-.444.965-.736.965-1.371 0-.825-.628-1.168-1.314-1.168-.803 0-1.253.478-1.342 1.134-.018.137-.128.25-.266.25h-.825zm2.325 6.443c-.584 0-1.009-.394-1.009-.927 0-.552.425-.94 1.01-.94.609 0 1.028.388 1.028.94 0 .533-.42.927-1.029.927z"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
<svg id="rot90" viewBox="0 0 225 225" xmlns="http://www.w3.org/2000/svg" xmlns:bx="https://boxy-svg.com">
|
||||||
|
<g transform="matrix(1, 0, 0, 1, 7, 20)">
|
||||||
|
<path style="fill: rgba(216, 216, 216, 0); stroke: rgb(13, 202, 240); stroke-width: 15px;" d="M 100.468 0.428 C 155.454 0.428 200.022 45.014 200 100"/>
|
||||||
|
<path d="M -100.468 -5.428 H -100.468 L -100.468 -20.428 L -60.468 -0.428 L -100.468 19.572 L -100.468 4.572 H -100.468 V -5.428 Z" style="fill: rgb(13, 202, 240);" transform="matrix(-1, 0, 0, -1, 0, 0)" bx:shape="arrow -100.468 -20.428 40 40 10 40 0 1@18b8b13c"/>
|
||||||
|
<text style="fill: rgb(13, 202, 240); font-family: Arial, sans-serif; font-size: 96px; font-weight: 700; white-space: pre;" transform="matrix(1, 0, 0, 1, -50.667503, 38.507301)"><tspan x="97.106" y="94.348">90</tspan><tspan x="97.106" dy="1em"></tspan></text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
<svg id="rot180" viewBox="0 0 225 225" xmlns:bx="https://boxy-svg.com">
|
||||||
|
<path style="fill: rgba(216, 216, 216, 0); paint-order: stroke; stroke-width: 15px; stroke: rgb(13, 202, 240);" d="M 70.624 -41.413 C 147.233 -41.507 195.215 41.367 156.992 107.76 C 139.252 138.572 106.422 157.581 70.867 157.624" transform="matrix(0, -1, 1, 0, 62.412816, 178.623736)"/>
|
||||||
|
<path d="M 0 95 H 0 L 0 80 L 40 100 L 0 120 L 0 105 H 0 V 95 Z" style="fill: rgb(13, 202, 240);" transform="matrix(0.000048, 1, -1, 0.000048, 120.999475, 107.995157)" bx:shape="arrow 0 80 40 40 10 40 0 1@de4046a6"/>
|
||||||
|
<text style="fill: rgb(13, 202, 240); font-family: Arial, sans-serif; font-size: 96px; font-weight: 700; white-space: pre;" transform="matrix(1, 0, 0, 1, -13.373604, 45.416005)"><tspan x="54.39" y="96.53">180</tspan><tspan x="54.39" dy="1em"></tspan></text>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
<svg id="rot270" viewBox="0 0 225 225" xmlns:bx="https://boxy-svg.com">
|
||||||
|
<g transform="matrix(1, 0, 0, 1, 8, 9)">
|
||||||
|
<path style="fill: rgba(13, 202, 240, 0); paint-order: fill; stroke: rgb(13, 202, 240); stroke-width: 15px;" d="M 100.308 199.384 C 177.051 199.384 225.015 116.307 186.644 49.846 C 148.272 -16.615 52.344 -16.615 13.972 49.846 C 5.371 64.744 0.771 81.615 0.62 98.817" transform="matrix(0, -1, 1, 0, 0.692227, 200.07649)"/>
|
||||||
|
<path d="M 99 195 H 99 L 99 180 L 139 200 L 99 220 L 99 205 H 99 V 195 Z" style="fill: rgb(13, 202, 240);" bx:shape="arrow 99 180 40 40 10 40 0 1@077af6d0"/>
|
||||||
|
<text style="fill: rgb(13, 202, 240); font-family: Arial, sans-serif; font-size: 96px; font-weight: 700; white-space: pre;" x="20.59" y="133.396">270</text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 23 KiB |
@@ -626,8 +626,8 @@ def RunJob(job):
|
|||||||
JobRestoreFiles(job)
|
JobRestoreFiles(job)
|
||||||
elif job.name == "run_ai_on":
|
elif job.name == "run_ai_on":
|
||||||
JobRunAIOn(job)
|
JobRunAIOn(job)
|
||||||
elif job.name == "rotate_image":
|
elif job.name == "transform_image":
|
||||||
JobRotateImage(job)
|
JobTransformImage(job)
|
||||||
else:
|
else:
|
||||||
print("ERROR: Requested to process unknown job type: {}".format(job.name))
|
print("ERROR: Requested to process unknown job type: {}".format(job.name))
|
||||||
# okay, we finished a job, so check for any jobs that are dependant on this and run them...
|
# okay, we finished a job, so check for any jobs that are dependant on this and run them...
|
||||||
@@ -1281,15 +1281,16 @@ def JobRunAIOn(job):
|
|||||||
return
|
return
|
||||||
|
|
||||||
####################################################################################################################################
|
####################################################################################################################################
|
||||||
# JobRotateImage(): rotate an image by the amount requested (can also flip horizontal or vertical)
|
# JobTransformImage(): transform an image by the amount requested (can also flip horizontal or vertical)
|
||||||
# TODO: should be JobTransformImage() ;)
|
# TODO: should be JobTransformImage() ;)
|
||||||
####################################################################################################################################
|
####################################################################################################################################
|
||||||
def JobRotateImage(job):
|
def JobTransformImage(job):
|
||||||
JobProgressState( job, "In Progress" )
|
JobProgressState( job, "In Progress" )
|
||||||
AddLogForJob(job, f"INFO: Starting rotation/flip of image file...")
|
AddLogForJob(job, f"INFO: Starting rotation/flip of image file...")
|
||||||
id=[jex.value for jex in job.extra if jex.name == "id"][0]
|
id=[jex.value for jex in job.extra if jex.name == "id"][0]
|
||||||
amt=[jex.value for jex in job.extra if jex.name == "amt"][0]
|
amt=[jex.value for jex in job.extra if jex.name == "amt"][0]
|
||||||
e=session.query(Entry).join(File).filter(Entry.id==id).first()
|
e=session.query(Entry).join(File).filter(Entry.id==id).first()
|
||||||
|
print( f"JobTransformImage: job={job.id}, id={id}, amt={amt}" )
|
||||||
im = Image.open( e.FullPathOnFS() )
|
im = Image.open( e.FullPathOnFS() )
|
||||||
|
|
||||||
if amt == "fliph":
|
if amt == "fliph":
|
||||||
@@ -1300,9 +1301,14 @@ def JobRotateImage(job):
|
|||||||
out = im.transpose(Image.FLIP_TOP_BOTTOM)
|
out = im.transpose(Image.FLIP_TOP_BOTTOM)
|
||||||
else:
|
else:
|
||||||
AddLogForJob(job, f"INFO: Rotating {e.FullPathOnFS()} by {amt} degrees" )
|
AddLogForJob(job, f"INFO: Rotating {e.FullPathOnFS()} by {amt} degrees" )
|
||||||
|
if im.format == 'JPEG':
|
||||||
|
im=ImageOps.exif_transpose(im)
|
||||||
out = im.rotate(int(amt), expand=True)
|
out = im.rotate(int(amt), expand=True)
|
||||||
out.save( e.FullPathOnFS() )
|
out.save( e.FullPathOnFS() )
|
||||||
|
print( f"JobTransformImage DONE transform: job={job.id}, id={id}, amt={amt}" )
|
||||||
e.file_details.thumbnail, _ , _ = GenThumb( e.FullPathOnFS() )
|
e.file_details.thumbnail, _ , _ = GenThumb( e.FullPathOnFS() )
|
||||||
|
e.file_details.hash = md5( job, e.FullPathOnFS() )
|
||||||
|
print( f"JobTransformImage DONE thumb: job={job.id}, id={id}, amt={amt}" )
|
||||||
session.add(e)
|
session.add(e)
|
||||||
FinishJob(job, "Finished Processesing image rotation/flip")
|
FinishJob(job, "Finished Processesing image rotation/flip")
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -317,7 +317,7 @@ $.contextMenu({
|
|||||||
}
|
}
|
||||||
if( e.currentTarget.getAttribute('type') == 'Image' )
|
if( e.currentTarget.getAttribute('type') == 'Image' )
|
||||||
{
|
{
|
||||||
item_list['rotate'] = {
|
item_list['transform'] = {
|
||||||
name: "Transform",
|
name: "Transform",
|
||||||
items: {
|
items: {
|
||||||
"r90": { "name" : "Rotate 90 degrees" },
|
"r90": { "name" : "Rotate 90 degrees" },
|
||||||
|
|||||||
@@ -86,6 +86,7 @@
|
|||||||
s+='<input type="hidden" name="folders" value="{{OPT.folders}}">'
|
s+='<input type="hidden" name="folders" value="{{OPT.folders}}">'
|
||||||
s+='<input type="hidden" name="how_many" value="{{OPT.how_many}}">'
|
s+='<input type="hidden" name="how_many" value="{{OPT.how_many}}">'
|
||||||
s+='<input type="hidden" name="orig_url" value="{{OPT.orig_url}}">'
|
s+='<input type="hidden" name="orig_url" value="{{OPT.orig_url}}">'
|
||||||
|
s+='<input type="hidden" name="fullscreen" value="' + fullscreen + '">'
|
||||||
s+='<input type="hidden" name="' + dir + '" value="1">'
|
s+='<input type="hidden" name="' + dir + '" value="1">'
|
||||||
{% if search_term is defined %}
|
{% if search_term is defined %}
|
||||||
s+='<input type="hidden" name="search_term" value="{{search_term}}">'
|
s+='<input type="hidden" name="search_term" value="{{search_term}}">'
|
||||||
@@ -271,10 +272,13 @@ $( document ).keydown(function(event) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log('here in viewer: fs = {{OPT.fullscreen}}')
|
||||||
var fullscreen=false;
|
var fullscreen=false;
|
||||||
{% if OPT.fullscreen=='true' %}
|
{% if OPT.fullscreen=='true' %}
|
||||||
|
console.log('fs is set')
|
||||||
fullscreen=true;
|
fullscreen=true;
|
||||||
ViewImageOrVideo()
|
ViewImageOrVideo()
|
||||||
|
console.log('have called view image, etc.')
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</script>
|
</script>
|
||||||
{% endblock script_content %}
|
{% endblock script_content %}
|
||||||
|
|||||||
Reference in New Issue
Block a user