w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Get Image Dimensions from Url in Python
Your main issue is you are searching the html source for references to height and width. In most cases (when things are done well), images don't have height and width specified in html, in which case they are rendered at the height and width of the image file itself. To get the height and width of the image file, you need to actually query for and load that file, then check the height and width using image processing. If this is what you want, let me know, and I'll help you work through that process. import urllib, cStringIO from PIL import Image # given an object called 'link' SITE_URL = "http://www.targetsite.com" URL = SITE_URL + link['src'] # Here's a sample url that works for demo purposes # URL = "http://therealtomrose.therealrosefamily.com/wp-content/uploads/2012/08/headshot_tig

Categories : Python

Getting dimensions of background-image
The issue is that some browsers add quotes to the CSS, and it was trying to load (in the fiddle's case) "http://fiddle.jshell.net/_display/%22http://placehold.it/200x300%22". I've updated your .replace() to look for " as well, and a fiddle is at http://jsfiddle.net/4uMEq/ $('#test').on('click', function () { $(this).text(getDimensions($(this))); }); var getDimensions = function (item) { var img = new Image(); img.src = item.css('background-image').replace(/url(|)$|"/ig, ''); return img.width + ' ' + img.height; };

Categories : Javascript

AVCaptureSession image dimensions (with GPUImage)
It is indeed possible to pull the dimensions out of the capture session. Here's how: // self.videoCamera is a GPUImageVideoCamera AVCaptureVideoDataOutput *output = [[[self.videoCamera captureSession] outputs] lastObject]; NSDictionary* outputSettings = [output videoSettings]; long width = [[outputSettings objectForKey:@"Width"] longValue]; long height = [[outputSettings objectForKey:@"Height"] longValue]; if (UIInterfaceOrientationIsPortrait([self.videoCamera outputImageOrientation])) { long buf = width; width = height; height = buf; } GPUImageMovieWriter * mw = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(width, height)];

Categories : IOS

Resizing each image based on dimensions in jQuery
You have a syntax error in your script, and '.thumbImage' must be set to a height of 100%: Syntax error: if( $(this).height() < $(this).width() || ($(this).height() == $(this).width() ) ) (You missed a closing bracket) CSS: .thumbImage { height:100%; } JS Fiddle: http://jsfiddle.net/fMhr2/1/ Also, you should calculate the ratio to get it to work properly, like Salketer just mentioned. I added that to this JSFiddle

Categories : Jquery

How calculate aspect ratio from dimensions of image
I think you are looking for HCF (Highest Common Factor) but the ratio (Width:835,Height:625) will be 167:125. Here is the function by which you can calculate HCF between 2 numbers. private int FindHCF(int m, int n) { int temp, reminder; if (m < n) { temp = m; m = n; n = temp; } while (true) { reminder = m % n; if (reminder == 0) return n; else m = n; n = reminder; } } So here is the rest of the code int hcf = FindHcf(835, 625); int factorW = 835 / hcf; int factorH = 625 / hcf;

Categories : C#

How to calculate dimensions after applying Matrix3D to image
Admittedly, I've never done this with a matrix applied, but, I believe you can use: image.getLayoutBoundsWidth(), image.getLayoutBoundsHeight(), image.getLayoutBoundsX(), and image.getLayoutBoundsY() to get these values. These methods from the ILayoutElement interface have a default boolean argument, postLayoutTransform (defaults to to true). When postLayoutTransform is true, the functions return values with the transformation applied.

Categories : Actionscript

How to get image dimensions before it's lazy loaded using jQuery?
Get the height of the image stored in the data-src attribute before it is lazy loaded in, add those together, then set the container to that height. Yes, because it is given that the width does not change. If it saves your time, you can also investigate plugins like imagesloaded and lazyload.

Categories : Javascript

Displaying dimensions of each image as caption or label
Here's a Fiddle HTML <img src="/" alt="Image"/> <img src="/" alt="Image"/> <img src="/" alt="Image"/> <img src="/" alt="Image"/> <img src="/" alt="Image"/> <img src="/" alt="Image"/> CSS img { width: 250px; /* For demo purposes */ height: 200px; /* For demo purposes */ border: none; } .img-wrapper { position: relative; float: left; margin: 0 12px 12px 0; border: 1px solid #555; } .img-wrapper span { display: block; text-align: center; } jQuery $(function() { $('img').each(function() { var image = $(this), imgW = $(this).outerWidth(), imgH = $(this).outerHeight(), size = '<span>'+imgW+'px X '+imgH+'px</span>'; $(this).wrap('<div class="img-wrapper">'+size+'</div>

Categories : Javascript

How do i get the image dimensions (height, width) from a file by using javascript
Bind the load event First, and then do all processing that needs the image to be loaded inside of the load event. function calculate(callback) { $("<img/>").load(function() { var pic_real_width = this.width; // Note: $(this).width() will not var pic_real_height = this.height; // work for in memory images. callback(pic_real_width,pic_real_height); }).attr("src", $("#pp_photo_popUp")[0].src); } calculate(function(width,height) { console.log(width,height); }); If you set the src first, some versions of IE will immediately trigger the load event synchronously, thus triggering it before you have even bound to it. That's why i swapped the order. Additionally, I added the callback parameter because I assume later in the function you were going to re

Categories : Javascript

if you know an image's dimensions, how do you scale it without a reflow in a fluid container
I think you may just be looking for overflow: hidden on the div. The only down side is if you expand the image too much it won't fit in the div. div { width: 50%; background-color: red; overflow:hidden; }

Categories : CSS

Images not being transformed to correct dimensions in image carousel
In Actual result jsfiddle, I changed #carousel a, img { display: block; float: left; border: none; position: relative; } to: #carousel a, #carousel img { display: block; float: left; border: none; position: relative; } Is that what your are looking as output, please run and see.

Categories : Javascript

Android 2.3.4: How do I determine the dimensions of an image to customize the layout during startup?
Create a bitmap from the drawable resource. Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); Once you have the bitmap, you can get the image dimensions through bitmap.getWidth() & bitmap.getHeight().

Categories : Android

OpenCV cvtColor() change my image dimensions and have wrong colors
It could be that "something passed as argument" does not have enough data to fill 720 lines. With some video cameras, not all three channels are represented using the same number of bits. For example, when capturing video on an iPhone, the three channels use 8-4-4 Bytes instead of 8-8-8. I haven't used this type of a camera with OpenCV, but most likely the problem is here.

Categories : C++

Changing the dimensions of a BitMapImage in WPF, and what kind of objects can I put in an element?
Ok, I figured out my question. Jeez, what a dummy. Below is the code I changed that got me the results I wanted: Uri uri = new Uri("pack://application:,,,/Images/DeployWiz_Network.png"); BitmapImage source = new BitmapImage(); source.BeginInit(); source.UriSource = uri; source.DecodePixelHeight = 10; source.DecodePixelWidth = 10; source.EndInit(); return source;

Categories : C#

Image in gui with gridlines convert to a textfile with N by M dimensions of the grid and the plotted points matlab
Here is an example. Main file This should be the main script. Grid_Size = [5 5]; Grid_Type = 1; % The group of the new clicked points. % Initialize Grid_Matrix = zeros(Grid_Size); grid_h = []; % Grid image handle fig_h = figure('Units', 'Normalized'); % Show your image rgb = imread('peppers.png'); im_h = imshow(rgb); % Shut off the 'HitTest' to keep the functionality of figure ButtonDownFcn set(im_h, 'HitTest', 'Off'); hold on % Hold on for the overlaying grid image. % Image normalized position Image_Pos = get(ancestor(im_h, 'axes'), 'Position'); im_size = size(rgb(:,:,1)); % Set the Mouse click callback for the figure (to a script in this case) set(fig_h, 'ButtonDownFcn', 'Mouse_Click'); Mouse_Click.m The script callback, I suggest script rather than function to avoid the com

Categories : Matlab

Getting image urls from a directory
JS: <script> function loadPHP() { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","somephp.php",true); //replace this with your file name xmlhttp.send(); } </script> HTML: <button onclick="loadPHP()">Click to load php</button> <div id="myDiv"></div> PHP: <?php $dir = "img"; if (is_dir($dir)){ if ($dh = opendir($dir)){ $images = array(); while (($file = readdir($d

Categories : PHP

php - get image urls from wordpress posts
This might help you out, here's a function that you can throw into your functions.php file in your Wordpress theme. /* * Retreive url's for image attachments from a post */ function getPostImages($size = 'full'){ global $post; $urls = array(); $images = get_children(array( 'post_parent' => $post->ID, 'post_status' => 'inheret', 'post_type' => 'attachment', 'post_mime_type' => 'image' )); if(isset($images)){ foreach($images as $image){ $imgThumb = wp_get_attachment_image_src($image->ID, $size, false); $urls[] = $imgThumb[0]; } return $urls; }else{ return false; } } That will return an array with each image url that is attached to the post/page.

Categories : PHP

Validating many image urls in PHP WITHOUT downloading
you can use a php function like "file_exists". for more information follow that link http://php.net/manual/en/function.file-exists.php or use this $file = 'http://www.abc.com/somefile.jpg'; $file_headers = @get_headers($file); if($file_headers[0] == 'HTTP/1.1 404 Not Found') { $exists = false; } else { $exists = true; }

Categories : PHP

Mini-pages and image urls
Sounds like you are using relative addresses, rather than absolute. Try prefixing with /, see where you need to put images for that, then putting all images there. You can still nest, just in absolute terms rather than relative (start with a /)

Categories : Meteor

PHP Regex to get all image URLs on the page
https?://[a-zA-Z0-9.]/[a-zA-Z0-9-&.]+.(jpg|png|gif|tif|exf|svg|wfm) I picked some arbitrary image types, and possibly missed a couple special characters allowed in URLs. Feel free to customize for your needs.

Categories : PHP

Rails please do not add /assets/ to my image urls
if you start your image paths with / they are relative to the projects document root, which is the public folder. image_tag 'foo.png' is rendered to /assets/foo.png image_tag '/uploadsave/foo.png' is rendered to /uploadsave/foo.png which is served from public/uploadsave/foo.png.

Categories : Ruby On Rails

Timestamp being appended to image urls using ? instead of &
ImageResizer does not modify URLs, nor is it aware of a 'timestamp' parameter — something else is causing this! It's apparent that there is either server-side logic/filtering making this occur, or else a javascript component modifying the DOM. Viewing the HTML source should tell you whether it's an HTML filter or a javascript snippet. Typically this kind of behavior is added by a 'debug mode' to eliminate browser caching. I'd watch for any debug settings and see if modifying them solves the problem. If so, please report back here as to the culprit.

Categories : Dotnet

Get all image urls when creating csv in magento
Try this if (count($product->getGalleryImages()) > 0) { foreach ($product->getGalleryImages() as $_image) { echo $this->getMediaConfig()->getMediaUrl($this->getData('image')); } } OR Mage::helper('catalog/image')->init($_product, 'image') This would work

Categories : Magento

What is the best way to get all image urls from an external web page in node.js
I ended up using the request node module along with cheerio and url. Here's what I ended up doing (please note, this is mvp code, not production quality): app.get('/scrape-images', function(req, res) { request(req.query.url, function (error, response, body) { if (!error && response.statusCode == 200) { var $ = cheerio.load(body); var reqUrl = url.parse(req.query.url); res.send($('img').map(function(i, e) { var srcUrl = url.parse($(e).attr('src')); if (!srcUrl.host) { return url.resolve(reqUrl, srcUrl); } else { return url.format(srcUrl); } })); } }); });

Categories : Node Js

Bash - change image urls to base64 in html
Your base64 encoded image can be multiple megabytes, while the system may place a limit on the maximum length of parameters (traditionally around 128k). Sed is also not guaranteed to handle lines over 8kb, though versions like GNU sed can deal with much more. If you want to try with your sed, provide the instructions in a file rather than on the command line. Instead of sed -e "s|$i|$k|" $1 > temp.html; use echo "s|$i|$k|" > foo.sed sed -f foo.sed "$1" > temp.html

Categories : Python

How to extract all image urls from a nested object or json string
Something like this should do the trick. I did not test though. function getAllImagesFromObject($obj) { $result = array(); foreach ($obj as $prop) if (is_array($prop) || is_object($prop)) $result = array_merge($result, getAllImagesFromObject($prop)); else if (preg_match('/.(jpg|jpeg|gif|png|bmp)$/', $prop)) $result[] = $prop; return $result; }

Categories : PHP

UrlRewrite IIS to make existing image urls work with ImageResizer
Was able to get the basic functionality to work with the following rule. <rule name="Redirect Category Name and Sort By" stopProcessing="true"> <match url="^image.aspx$" ignoreCase="true" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="true"> <add input="{QUERY_STRING}" pattern="^imageid=([0-9]+)" /> </conditions> <action type="Rewrite" url="image/{C:1}.jpg" appendQueryString="true" /> </rule>

Categories : Iis

How to exctract all image urls and href value from html string using javascript?
If you're using jQuery then you can do: var data = []; $($.parseHTML(siteContents)).each(function() { $(this).find("img").each(function() { var parent = $(this).parent(); data.push({ SRC: $(this).attr("src"), HREF: parent.find("a").attr("href"), LOCATION: parent.find(".location").text(), PRICE: parent.find(".price").text(), SUBJECT: parent.find(".subject li").text() }); }); }); You can then use the array "data" that contains objects. Each of which has a "SRC", and "HREF" attribute associated with it. See this jsFiddle for an example of it in use. UPDATED BASED ON COMMENTS See this jsFiddle example. The key change is instead of looking for "li" y

Categories : Javascript

How to fetch an array of image URLs with node.js and save to s3 asynchronously?
There are several things you could improve with your code: HTTP Agent First of all, node.js uses an HTTP Agent, which limits the number of concurrent connections to a host. If it wasn't, you could easily accidentally hammer websites with thousands of connections. You can disable it by passing {agent: false} to request. Note that knox already disables it. I suspect this is the reason why your code runs sequentially. Async.each Async.each will run all iterations in parallel. When you are calling nextImage(), you are not telling async to start the next iteration, but rather say that you are done. Async completes when all iterations are done. The problem here is that you keep doing work after you told async that you were finished.

Categories : Node Js

Capture and use all image URLs in a SASS file with a view to using css-only preload
You can use SASS mixins, functions and lists for that. First, you create a mixin background-image that will add a background-image property and will append the image to a SASS list preload-images. /* '$img-path' is in your case 'img01.png' or 'img02.png' */ @mixin background-image($img-path) { background-image: url($img-path); $tmp: preload-image($img-path); } Then you define the function preload-image along with a list $preloaded-images. The function appends url($img-path) to the $preloaded-images list. /* Preloaded images */ $preloaded-images: null; @function preload-image($image-path) { $preloaded-images: $preloaded-images url($image-url); @return $preloaded-images; } Every time you want to use a background image, you use the background-image mixin. Then, at the end of you

Categories : CSS

Konacha adds 'iframe' to image urls that have the src attribute set programmatically
assets/dir/filename.jpg is a relative path; it is interpreted relative to the base URL of the page, which is http://0.0.0.0:3500/iframe/, producing http://0.0.0.0:3500/iframe/assets/dir/filename.jpg. You'll want to use the absolute path /assets/dir/filename.jpg instead, with a leading slash.

Categories : Image

Child image absolutely positioned, w/ dynamic dimensions. Need parent to have dynamic height to match the childs
I figured it out. I added a blank image of the same proportions as my slideshow images after the slide show and set its z-index to -1. This allowed the parent div to fit around the blank image and adjust accordingly around the slide show. HTML <div class="slideshowContainer"> <ul id="horizontal-style"> <li><a href=# >Home</a></li> <li><a href=# >About Us</a></li> <li><a href=# >Online Courses</a></li> <li><a href=# >Registration</a></li> <li><a href=# >Faculty</a></li> <li><a href=# >Calendar</a></li> <li><a href=# >Store</a></li> <li><a href=# >

Categories : Image

Clickable picture array image output size - can't control dimensions of individual output pictures
you can change an image's size by its height and width properties. Note that this resizes the image, and can be subject to warping. It is suggested that you resize a large image to smaller thumbnails, because it is extremely wasteful to request a huge image then to style it to be a small thumbnail image. You can rather easily create a script that will resize images for you to an number and combination of sizes

Categories : Javascript

How to valiate if list of image URLs exist before feeding them to javascript plugin?
Make a HEAD Ajax request Are your images hosted on the same domain? If so, you could make an Ajax type "HEAD" request to see if it is a 404, without retrieving the contents of the image itself. This should make your initial check quite fast and efficient. See this thread for an example that I think is somewhat similar to what you are looking to accomplish: Ajax HEAD request via Javascript/jQuery Do it server side If your images are not on the same domain, or you need to support older browsers that may not be able to do HEAD Ajax requests, I'd be tempted to verify your URLs server side. Do this before the page loads, or if you can't, make an Ajax call to your own server side script. The server side script can get the headers for each URL (again without pulling the image data itself) and

Categories : Javascript

JS - File Reader API get image file size and dimensions
Something like this? var oPreviewImg = new Image(); oPreviewImg.onload = function(){ console.log(oPreviewImg); alert("'" + oPreviewImg.name + "' is " + oPreviewImg.width + " by " + oPreviewImg.height + " pixels in size."); return true; }; oPreviewImg.onerror = function(){ alert("'" + this.name + "' failed to load."); return true; } oPreviewImg.src = "http://projects.bygph.com/inconsistency2.png"; //Size var xhr = new XMLHttpRequest(); xhr.open('HEAD', oPreviewImg.src, true); xhr.onreadystatechange = function(){ if ( xhr.readyState == 4 ) { if ( xhr.status == 200 ) { alert('Size in bytes: ' + xhr.getResponseHeader('Content-Length')); } else { alert('ERROR'); } } }; xhr.send(null); Live version

Categories : Javascript

How can I get refinerycms to display uploaded image urls from Amazon S3 versus /system/images...?
Ok I figured this out and it may be applicable to you. I found the answer here: https://github.com/refinery/refinerycms/issues/1863 Basically you are likely mounting the Refinery CMS engine at a different mount point than route. You need to set where you are mounting Refinery so that the images will pick up properly. config.dragonfly_url_host = "/my-mount-point"

Categories : Ruby On Rails

d3js basic javascript&css: how to I apply an array of strings (for image urls) to the existing bar chart?
Here's one way to accomplish your goal (revised version of your code sample posted on jsbin). http://jsbin.com/ocoyal/1/edit CSS div.bar { display: inline-block; width: 20px; height: 75px; /* Gets overriden by D3-assigned height below */ margin-right: 2px; background-image: url('http://4.bp.blogspot.com/-HWtqJNu3blk/UOhy_vj2I3I/AAAAAAAAhdY/U-krgiDfksw/s640/sydney+australia+rubber+duck+1.jpg'); /* https://developer.mozilla.org/en-US/docs/Web/CSS/background-size */ background-size: cover; background-repeat: no-repeat; } JavaScript var dataset = [ 25, 7, 5]; var coverset=['http://4.bp.blogspot.com/-HWtqJNu3blk/UOhy_vj2I3I/AAAAAAAAhdY/U-krgiDfksw/s640/sydney+australia+rubber+duck+1.jpg', 'http://fora.mtv.ca/wp-

Categories : Javascript

How to get dimensions for a background image when background-size is set to contain?
Try like var wdth = $('.logo-container img').width(); var hght = $('.logo-container img').height(); Or you can get the div height and width also like var wdth = $('.logo-container').width(); Because the image is the background image of that div.

Categories : Jquery

Python HTML parsing script that takes array of URLs and outputs specific data about each of the URLs
import urllib2 from bs4 import BeautifulSoup url = 'http://www.youtube.com/watch?v=QOdW1OuZ1U0' f = urllib2.urlopen(url) data = f.read() soup = BeautifulSoup(data) span = soup.find('span', attrs={'class':'watch-view-count'}) print '{}:{}'.format(url, span.text) If you do not want to use BeautifulSoup, you can use re: import urllib2 import re url = 'http://www.youtube.com/watch?v=QOdW1OuZ1U0' f = urllib2.urlopen(url) data = f.read() pattern = re.compile('<span class="watch-view-count.*?([d,]+).*?</span>', re.DOTALL) r = pattern.search(data) print '{}:{}'.format(url, r.group(1)) As for the outputs, I think you can store them in a csv file.

Categories : Python

How can i read a file for urls and then launch all the urls in browser using python
with open('Path/to/file', 'r') as content_file: content = content_file.read() urls = content.split() for url in urls: webbrowser.open(url) You can also try webbrowser.open(url, 2) to try to open the links in new tabs.

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.