Skip to content

Commit

Permalink
screenshot issues fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali Abid committed Jul 21, 2020
1 parent baa7ef3 commit f78e6eb
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 17 deletions.
12 changes: 11 additions & 1 deletion build/lib/gradio/static/css/gradio.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ input.submit {
}
input.panel_button {
background-color: whitesmoke;
flex-grow: 1;
padding: 12px;
box-sizing: border-box;
font-weight: bold;
Expand Down Expand Up @@ -99,4 +98,15 @@ input.submit:hover {
}
.screenshot {
visibility: hidden;
}
.screenshot_logo {
display: none;
flex-grow: 1;
text-align: center;
padding: 4px;
box-sizing: border-box;
margin-left: 16px;
}
.screenshot_logo img {
height: 38px;
}
12 changes: 9 additions & 3 deletions build/lib/gradio/static/css/interfaces/output/image.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
.output_image {
.output_image_holder {
width: 100%;
height: 100%;
object-fit: contain;
display: none
display: flex;
justify-content: center;
align-items: center;
}
.output_image {
max-width: 100%;
max-height: 100%;
display: none;
}
9 changes: 8 additions & 1 deletion build/lib/gradio/static/js/gradio.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ function gradio(config, fn, target) {
</div>
<div class="panel_buttons">
<input class="screenshot panel_button" type="button" value="SCREENSHOT"/>
<div class="screenshot_logo">
<img src="static/img/logo_inline.png">
</div>
</div>
</div>
</div>`);
Expand Down Expand Up @@ -125,9 +128,13 @@ function gradio(config, fn, target) {
target.find(".screenshot").css("visibility", "visible");
}
target.find(".screenshot").click(function() {
$(".screenshot").hide();
$(".screenshot_logo").show();
html2canvas(target[0]).then(function(canvas) {
saveAs(canvas.toDataURL(), 'screenshot.png');
});
$(".screenshot").show();
$(".screenshot_logo").hide();
});
});
if (config.live) {
io_master.gather();
Expand Down
4 changes: 3 additions & 1 deletion build/lib/gradio/static/js/interfaces/output/image.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const image_output = {
html: `
<img class="output_image" />
<div class="output_image_holder">
<img class="output_image" />
</div>
`,
init: function(opts) {},
output: function(data) {
Expand Down
10 changes: 5 additions & 5 deletions demo/flip_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ def flip2(image):
def flip10(i1, i2, i3, i4, i5):
return i1 + i2

gr.Interface(flip10,
["image"] * 5,
gr.Interface(flip2,
["image"],
["image"],
examples=[
["images/cheetah1.jpg"] * 5,
["images/cheetah2.jpg"] * 5,
["images/lion.jpg"] * 5,
["images/cheetah1.jpg"],
["images/cheetah2.jpg"],
["images/lion.jpg"],
]
).launch()
12 changes: 11 additions & 1 deletion gradio/static/css/gradio.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ input.submit {
}
input.panel_button {
background-color: whitesmoke;
flex-grow: 1;
padding: 12px;
box-sizing: border-box;
font-weight: bold;
Expand Down Expand Up @@ -99,4 +98,15 @@ input.submit:hover {
}
.screenshot {
visibility: hidden;
}
.screenshot_logo {
display: none;
flex-grow: 1;
text-align: center;
padding: 4px;
box-sizing: border-box;
margin-left: 16px;
}
.screenshot_logo img {
height: 38px;
}
12 changes: 9 additions & 3 deletions gradio/static/css/interfaces/output/image.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
.output_image {
.output_image_holder {
width: 100%;
height: 100%;
object-fit: contain;
display: none
display: flex;
justify-content: center;
align-items: center;
}
.output_image {
max-width: 100%;
max-height: 100%;
display: none;
}
9 changes: 8 additions & 1 deletion gradio/static/js/gradio.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ function gradio(config, fn, target) {
</div>
<div class="panel_buttons">
<input class="screenshot panel_button" type="button" value="SCREENSHOT"/>
<div class="screenshot_logo">
<img src="static/img/logo_inline.png">
</div>
</div>
</div>
</div>`);
Expand Down Expand Up @@ -125,9 +128,13 @@ function gradio(config, fn, target) {
target.find(".screenshot").css("visibility", "visible");
}
target.find(".screenshot").click(function() {
$(".screenshot").hide();
$(".screenshot_logo").show();
html2canvas(target[0]).then(function(canvas) {
saveAs(canvas.toDataURL(), 'screenshot.png');
});
$(".screenshot").show();
$(".screenshot_logo").hide();
});
});
if (config.live) {
io_master.gather();
Expand Down
4 changes: 3 additions & 1 deletion gradio/static/js/interfaces/output/image.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const image_output = {
html: `
<img class="output_image" />
<div class="output_image_holder">
<img class="output_image" />
</div>
`,
init: function(opts) {},
output: function(data) {
Expand Down

0 comments on commit f78e6eb

Please sign in to comment.