snipt

Ctrl+h for KB shortcuts
Notice: Snipt is moving away from free accounts on May 1st, 2014. Read more about the transition here.
#35616

PHP

Ancho y alto de una imagen

1
2
3
4
5
6
<?php
  $file = imagen.jpg;
  $imagen = getimagesize($file);    //Sacamos la informacion de la imagen
  $ancho = $imagen[0];              //Ancho de la imagen
  $alto = $imagen[1];               //Alto de la imagen
?>
https://snipt.net/embed/095eeec1f4768cf0b9c7efdd6e625893/
https://snipt.net/raw/095eeec1f4768cf0b9c7efdd6e625893/
095eeec1f4768cf0b9c7efdd6e625893
php
PHP
7
2014-04-14T23:39:24
True
False
/api/public/snipt/35616/
ancho-y-alto-de-una-imagen
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a> <span class="nv">$file</span> <span class="o">=</span> <span class="nx">imagen</span><span class="o">.</span><span class="nx">jpg</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a> <span class="nv">$imagen</span> <span class="o">=</span> <span class="nb">getimagesize</span><span class="p">(</span><span class="nv">$file</span><span class="p">);</span> <span class="c1">//Sacamos la informacion de la imagen</span> </span><span id="L-4"><a name="L-4"></a> <span class="nv">$ancho</span> <span class="o">=</span> <span class="nv">$imagen</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span> <span class="c1">//Ancho de la imagen</span> </span><span id="L-5"><a name="L-5"></a> <span class="nv">$alto</span> <span class="o">=</span> <span class="nv">$imagen</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span> <span class="c1">//Alto de la imagen</span> </span><span id="L-6"><a name="L-6"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
alto, ancho, dimensiones
#35423

JavaScript

alto javascript

1
2
3
4
5
6
function getBrowserHeight(){
    if (window.innerHeight) return window.innerHeight;
    else if (document.documentElement && document.documentElement.clientHeight != 0) return document.documentElement.clientHeight;    
    else if (document.body) return document.body.clientHeight;
    return 0;
}  
https://snipt.net/embed/7251f6f08fcce9f83ab90f4442f85f68/
https://snipt.net/raw/7251f6f08fcce9f83ab90f4442f85f68/
7251f6f08fcce9f83ab90f4442f85f68
js
JavaScript
7
2014-04-17T09:50:17
True
False
/api/public/snipt/35423/
alto-javascript
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="kd">function</span> <span class="nx">getBrowserHeight</span><span class="p">(){</span> </span><span id="L-2"><a name="L-2"></a> <span class="k">if</span> <span class="p">(</span><span class="nb">window</span><span class="p">.</span><span class="nx">innerHeight</span><span class="p">)</span> <span class="k">return</span> <span class="nb">window</span><span class="p">.</span><span class="nx">innerHeight</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nb">document</span><span class="p">.</span><span class="nx">documentElement</span> <span class="o">&amp;&amp;</span> <span class="nb">document</span><span class="p">.</span><span class="nx">documentElement</span><span class="p">.</span><span class="nx">clientHeight</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">)</span> <span class="k">return</span> <span class="nb">document</span><span class="p">.</span><span class="nx">documentElement</span><span class="p">.</span><span class="nx">clientHeight</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nb">document</span><span class="p">.</span><span class="nx">body</span><span class="p">)</span> <span class="k">return</span> <span class="nb">document</span><span class="p">.</span><span class="nx">body</span><span class="p">.</span><span class="nx">clientHeight</span><span class="p">;</span> </span><span id="L-5"><a name="L-5"></a> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span> </span><span id="L-6"><a name="L-6"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
alto, altura