2017-01-03 22 views
-1

卓上にダウンロードすると画像が見えます。私は犬の画像を持つ画像にdivを変換することはできませんbu私はそれに犬の画像で画像をダウンロードすることができるようです。なぜそれが起こるだろうか?誰かがここで解決策を見つける私を助けてくださいすることができ、ライブビューでhttp://torcdesign.com/banana/画像をダウンロードして画像をダウンロードするには

$(document).ready(function() { 
 
    $('#imajes').change(function() { 
 
    $('.subselector').hide(); 
 
    $('.smallimages').hide(); 
 
    $('#' + $(this).val()).show(); 
 
\t 
 
    }); 
 
    
 
    $('.smallimages').hide(); 
 
    var id = $(this).attr('id'); 
 
    var val = $(this).val(); 
 
\t 
 
\t 
 
$('#dog').on('change', function() { 
 
    
 
    $("#bulldogimges").css('display', (this.value == 'bulldog') ? 'block' : 'none'); 
 

 

 
    $("#huntingdogimges").css('display', (this.value == 'huntingdog') ? 'block' : 'none'); 
 
    $("#germandogimges").css('display', (this.value == 'policedog') ? 'block' : 'none'); 
 
}); 
 

 
$('img').on('click', function() { 
 
    $('#fotos').append('<div class="imgdrag"><img class="modal-content" src="' + $(this).attr('src')+ '"/></div>'); $('.imgdrag').draggable(); 
 
$('#fotos').droppable(); 
 
\t   $('.modal-content').resizable(); 
 

 

 

 
}); 
 

 
    
 
    
 
}); 
 

 

 
var download = document.getElementById("download"), 
 
\t \t result = document.getElementById("previewImage"); 
 

 
function renderContent() { 
 
    html2canvas(document.getElementById("firstshirt"), { 
 
     allowTaint: true 
 
    }).then(function(canvas) { 
 
    \t \t result.appendChild(canvas); 
 
     download.style.display = "inline"; download.href = result.children[0].toDataURL(); 
 
    }); 
 
} 
 

 
function downloadImage() { 
 
\t \t 
 
} 
 

 
document.getElementById("btn-Preview-Image").onclick = renderContent; 
 
download.onclick = downloadImage
.container {background-color: transparent; 
 
    width: 300px; 
 
    height: 300px; 
 
    border: 2px solid red; 
 
    position: relative; 
 
overflow: hidden; 
 

 
/* Will stretch to specified width/height */ 
 
    background-size: 490px 500px; 
 
    background-repeat: no-repeat; 
 
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.1/knockout-min.js"></script> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
 
<script type="text/javascript" 
 
\t src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script> 
 

 
<script src="https://rawgit.com/niklasvh/html2canvas/master/dist/html2canvas.min.js"></script> 
 
<script src="https://hongru.github.io/proj/canvas2image/canvas2image.js"></script> 
 

 
<script 
 
src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script><script src="//cdnjs.cloudflare.com/ajax/libs/knockout/2.3.0/knockout-min.js"></script> 
 
<link rel="stylesheet" 
 
href="https://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" /> 
 
    <script src="https://code.jquery.com/ui/1.9.2/jquery-ui.js"></script> 
 
    <link rel="stylesheet" 
 
href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.3/FileSaver.min.js"></script> 
 
<script src="//code.jquery.com/jquery-1.10.2.js"></script> 
 
<link href='https://fonts.googleapis.com/css?family=Philosopher' rel='stylesheet' type='text/css'> 
 
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> 
 
<script src="https://rawgit.com/niklasvh/html2canvas/master/dist/html2canvas.js"></script> 
 
<script src="https://files.codepedia.info/uploads/iScripts/html2canvas.js"></script> 
 

 
<select id="imajes"> 
 
     <option value="">Choose Image</option> 
 
     
 
     <option value="dog">Dog</option> 
 
     
 
    </select> 
 

 
<select id="dog" name="subselector" class="subselector" style="display:none"> 
 
    <option value="">Choose an item</option> 
 
    <option value="bulldog">Bulldog</option> 
 
    <option value="huntingdog">Hunting Dog</option> 
 
    <option value="policedog">German Shepherd</option> 
 
</select> 
 
<div id="firstshirt" class="container" style="float:left;"><div id="fotos" ><img class="modal-content" id="imgdisplay" /></div></div> 
 
<input id="btn-Preview-Image" type="button" value="Preview"/><a id="download" download="my_image.png" href="#">Download image</a> 
 
<h3>result:</h3> 
 
<div> <div id="previewImage"> 
 
    </div><a id="download" download="my_image.png" href="#">Download image</a></div> 
 
    
 
    <div style='display:none;' id="bulldogimges" class="smallimages"> 
 
<div class="imgcontainerss" data-image="https://torcdesign.com/clipart/pT78gE6pc.gif"> 
 
    <img src="https://torcdesign.com/clipart/pT78gE6pc.gif" alt="Smiley face" width="55" height="55"> 
 
    </div> 
 
<div class="imgcontainerss" data-image="https://torcdesign.com/clipart/LiKkRqkeT.gif"> 
 
    <img src="https://torcdesign.com/clipart/LiKkRqkeT.gif" alt="Smiley face" width="55" height="55"> 
 
    </div> 
 
<div class="imgcontainerss" data-image="https://torcdesign.com/clipart/free-bulldog-clipart-031350.gif"> 
 
    <img src="https://torcdesign.com/clipart/free-bulldog-clipart-031350.gif" alt="Smiley face" width="55" height="55"> 
 
    </div> 
 

 
</div>

+0

あなたdownloadImage()メソッドはnullを実装したものです。それには文が含まれていません。 – Rajashekhar

答えて

1

あなたは、更新されたコードをチェックすることができます

私はダウンロードのイメージボタンのコードを更新しましたが。

$(document).ready(function() { 
 
    $('#imajes').change(function() { 
 
    $('.subselector').hide(); 
 
    $('.smallimages').hide(); 
 
    $('#' + $(this).val()).show(); 
 
\t 
 
    }); 
 
    
 
    $('.smallimages').hide(); 
 
    var id = $(this).attr('id'); 
 
    var val = $(this).val(); 
 
\t 
 
\t 
 
$('#dog').on('change', function() { 
 
    
 
    $("#bulldogimges").css('display', (this.value == 'bulldog') ? 'block' : 'none'); 
 

 

 
    $("#huntingdogimges").css('display', (this.value == 'huntingdog') ? 'block' : 'none'); 
 
    $("#germandogimges").css('display', (this.value == 'policedog') ? 'block' : 'none'); 
 
}); 
 

 
$('img').on('click', function() { 
 
    $('#fotos').append('<div class="imgdrag"><img class="modal-content" src="' + $(this).attr('src')+ '"/></div>'); $('.imgdrag').draggable(); 
 
$('#fotos').droppable(); 
 
\t   $('.modal-content').resizable(); 
 

 

 
$(".download").attr("href",$(this).attr('src')); 
 
    $(".download").show(); 
 
}); 
 

 
    
 
    
 
}); 
 

 

 
var download = document.getElementById("download"), 
 
\t \t result = document.getElementById("previewImage"); 
 

 
function renderContent() { 
 
    html2canvas(document.getElementById("firstshirt"), { 
 
     allowTaint: true 
 
    }).then(function(canvas) { 
 
    \t \t result.appendChild(canvas); 
 
     download.style.display = "inline"; download.href = result.children[0].toDataURL(); 
 
    }); 
 
} 
 

 
function downloadImage() { 
 
\t \t 
 
} 
 

 
document.getElementById("btn-Preview-Image").onclick = renderContent; 
 
download.onclick = downloadImage
.container {background-color: transparent; 
 
    width: 300px; 
 
    height: 300px; 
 
    border: 2px solid red; 
 
    position: relative; 
 
overflow: hidden; 
 

 
/* Will stretch to specified width/height */ 
 
    background-size: 490px 500px; 
 
    background-repeat: no-repeat; 
 
} 
 

 
.download{ 
 
display:none; 
 

 
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.1/knockout-min.js"></script> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
 
<script type="text/javascript" 
 
\t src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script> 
 

 
<script src="https://rawgit.com/niklasvh/html2canvas/master/dist/html2canvas.min.js"></script> 
 
<script src="https://hongru.github.io/proj/canvas2image/canvas2image.js"></script> 
 

 
<script 
 
src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script><script src="//cdnjs.cloudflare.com/ajax/libs/knockout/2.3.0/knockout-min.js"></script> 
 
<link rel="stylesheet" 
 
href="https://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" /> 
 
    <script src="https://code.jquery.com/ui/1.9.2/jquery-ui.js"></script> 
 
    <link rel="stylesheet" 
 
href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.3/FileSaver.min.js"></script> 
 
<script src="//code.jquery.com/jquery-1.10.2.js"></script> 
 
<link href='https://fonts.googleapis.com/css?family=Philosopher' rel='stylesheet' type='text/css'> 
 
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> 
 
<script src="https://rawgit.com/niklasvh/html2canvas/master/dist/html2canvas.js"></script> 
 
<script src="https://files.codepedia.info/uploads/iScripts/html2canvas.js"></script> 
 

 
<select id="imajes"> 
 
     <option value="">Choose Image</option> 
 
     
 
     <option value="dog">Dog</option> 
 
     
 
    </select> 
 

 
<select id="dog" name="subselector" class="subselector" style="display:none"> 
 
    <option value="">Choose an item</option> 
 
    <option value="bulldog">Bulldog</option> 
 
    <option value="huntingdog">Hunting Dog</option> 
 
    <option value="policedog">German Shepherd</option> 
 
</select> 
 
<div id="firstshirt" class="container" style="float:left;"><div id="fotos" ><img class="modal-content" id="imgdisplay" /></div></div> 
 
<input id="btn-Preview-Image" type="button" value="Preview"/><a class="download" id="download" download="my_image.png" href="#">Download image</a> 
 
<h3>result:</h3> 
 
<div> <div id="previewImage"> 
 
    </div><a id="download" class="download" download="my_image.png" href="#">Download image</a></div> 
 
    
 
    <div style='display:none;' id="bulldogimges" class="smallimages"> 
 
<div class="imgcontainerss" data-image="https://torcdesign.com/clipart/pT78gE6pc.gif"> 
 
    <img src="https://torcdesign.com/clipart/pT78gE6pc.gif" alt="Smiley face" width="55" height="55"> 
 
    </div> 
 
<div class="imgcontainerss" data-image="https://torcdesign.com/clipart/LiKkRqkeT.gif"> 
 
    <img src="https://torcdesign.com/clipart/LiKkRqkeT.gif" alt="Smiley face" width="55" height="55"> 
 
    </div> 
 
<div class="imgcontainerss" data-image="https://torcdesign.com/clipart/free-bulldog-clipart-031350.gif"> 
 
    <img src="https://torcdesign.com/clipart/free-bulldog-clipart-031350.gif" alt="Smiley face" width="55" height="55"> 
 
    </div> 
 

 
</div>

+0

それは動作しますが、一度それを私の残りのものと一緒に挿入すれば、まだ空のimgが得られます – xcalliber

+0

ここにURLがありますので、私は非常に残念なことを話しています。http://stackoverflow.com/questions/41435701/converting-div -with-other-images-inside-into-image?noredirect = 1#comment70077430_41435701 – xcalliber

+0

ダウンロードリンクにhrefを割り当てる必要があります。上記の質問は保留中です。だから私はそれに答えることができない。 –

関連する問題