1
0
Fork 0
mirror of synced 2024-06-18 19:04:30 +12:00

Add download button for mobile

This commit is contained in:
nagadomi 2015-11-21 16:01:49 +09:00
parent 92d2672348
commit 26f0d61bb1
4 changed files with 10 additions and 1 deletions

View file

@ -48,6 +48,7 @@
<label><input type="radio" name="scale" value="2"> 2x</label>
</fieldset>
<input type="submit"/>
<input type="submit" name="download" value="Download"/>
</form>
<div class="help">
<ul class="padding-left">

View file

@ -45,6 +45,7 @@
<label><input type="radio" name="scale" value="2"> 2x</label>
</fieldset>
<input type="submit" value="実行"/>
<input type="submit" name="download" value="ダウンロード"/>
</form>
<div class="help">
<ul class="padding-left">

View file

@ -47,6 +47,7 @@
<label><input type="radio" name="scale" value="2"> 2x</label>
</fieldset>
<input type="submit"/>
<input type="submit" name="download" value="Download"/>
</form>
<div class="help">
<ul class="padding-left">

View file

@ -156,6 +156,8 @@ function APIHandler:post()
local noise = tonumber(self:get_argument("noise", "0"))
local white_noise = tonumber(self:get_argument("white_noise", "0"))
local style = self:get_argument("style", "art")
local download = (self:get_argument("download", "")):len()
if style ~= "art" then
style = "photo" -- style must be art or photo
end
@ -189,8 +191,12 @@ function APIHandler:post()
local name = uuid() .. ".png"
local blob = image_loader.encode_png(x, alpha)
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))
if download > 0 then
self:set_header("Content-Type", "application/octet-stream")
else
self:set_header("Content-Type", "image/png")
end
self:write(blob)
else
if not x then