Add download button for mobile
This commit is contained in:
parent
92d2672348
commit
26f0d61bb1
4 changed files with 10 additions and 1 deletions
|
@ -48,6 +48,7 @@
|
||||||
<label><input type="radio" name="scale" value="2"> 2x</label>
|
<label><input type="radio" name="scale" value="2"> 2x</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<input type="submit"/>
|
<input type="submit"/>
|
||||||
|
<input type="submit" name="download" value="Download"/>
|
||||||
</form>
|
</form>
|
||||||
<div class="help">
|
<div class="help">
|
||||||
<ul class="padding-left">
|
<ul class="padding-left">
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
<label><input type="radio" name="scale" value="2"> 2x</label>
|
<label><input type="radio" name="scale" value="2"> 2x</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<input type="submit" value="実行"/>
|
<input type="submit" value="実行"/>
|
||||||
|
<input type="submit" name="download" value="ダウンロード"/>
|
||||||
</form>
|
</form>
|
||||||
<div class="help">
|
<div class="help">
|
||||||
<ul class="padding-left">
|
<ul class="padding-left">
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
<label><input type="radio" name="scale" value="2"> 2x</label>
|
<label><input type="radio" name="scale" value="2"> 2x</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<input type="submit"/>
|
<input type="submit"/>
|
||||||
|
<input type="submit" name="download" value="Download"/>
|
||||||
</form>
|
</form>
|
||||||
<div class="help">
|
<div class="help">
|
||||||
<ul class="padding-left">
|
<ul class="padding-left">
|
||||||
|
|
8
web.lua
8
web.lua
|
@ -156,6 +156,8 @@ function APIHandler:post()
|
||||||
local noise = tonumber(self:get_argument("noise", "0"))
|
local noise = tonumber(self:get_argument("noise", "0"))
|
||||||
local white_noise = tonumber(self:get_argument("white_noise", "0"))
|
local white_noise = tonumber(self:get_argument("white_noise", "0"))
|
||||||
local style = self:get_argument("style", "art")
|
local style = self:get_argument("style", "art")
|
||||||
|
local download = (self:get_argument("download", "")):len()
|
||||||
|
|
||||||
if style ~= "art" then
|
if style ~= "art" then
|
||||||
style = "photo" -- style must be art or photo
|
style = "photo" -- style must be art or photo
|
||||||
end
|
end
|
||||||
|
@ -189,8 +191,12 @@ function APIHandler:post()
|
||||||
local name = uuid() .. ".png"
|
local name = uuid() .. ".png"
|
||||||
local blob = image_loader.encode_png(x, alpha)
|
local blob = image_loader.encode_png(x, alpha)
|
||||||
self:set_header("Content-Disposition", string.format('filename="%s"', name))
|
self:set_header("Content-Disposition", string.format('filename="%s"', name))
|
||||||
self:set_header("Content-Type", "image/png")
|
|
||||||
self:set_header("Content-Length", string.format("%d", #blob))
|
self:set_header("Content-Length", string.format("%d", #blob))
|
||||||
|
if download > 0 then
|
||||||
|
self:set_header("Content-Type", "application/octet-stream")
|
||||||
|
else
|
||||||
|
self:set_header("Content-Type", "image/png")
|
||||||
|
end
|
||||||
self:write(blob)
|
self:write(blob)
|
||||||
else
|
else
|
||||||
if not x then
|
if not x then
|
||||||
|
|
Loading…
Reference in a new issue