Tag Archives: image

Solved: Image in div has a Thin Line Underneath Programming 11 JUN 2015

I noticed an annoying issue while working on some design elements on the survey element of my configurable feedback system Kinetica (for Touchwork) the other day. Essentially an image nestled inside a <div> element was rendering with an unsightly little line of space underneath it, breaking the visual effect that I wanted.

Perplexed (because the CSS inspector wasn’t showing anything untoward), I turned to Google and pretty soon had both the reason and the solution.

As it turns out, by default images are rendered as inline elements as opposed to block elements. In other words, it is rendered and treated like a letter/character, meaning that by default the line it is on has space below for the ‘descenders’ that you find on letters like y, j, p and q. This is then the line that you see below the image, because obviously it sits square on the line.

There are three possible fixes you can employ here. If you don’t want to do anything unnatural, you can get around the problem by simply specifying an appropriate vertical-align css style on the image, e.g. style=”vertical-align:bottom;”

Another fix that will work quite nicely is by specifying the line height of the parent container to 0 pixels, e.g. #div { line-height: 0;} <- of course, this assumes that you’re not going to have text anywhere in this parent container.

Finally, a just as effective trick would be to simply declare the image to be displayed as a block element, e.g. style=”display:block”

So with all that said and done, employing any of the tricks above will turn this:

thin line under image in div

into this:

thin line under image in div solved

Related Link: W3Schools

Amy Reeder: Halloween Eve Cover (2012) Comic Book Art | Comic Books 01 JAN 2013

Eve has an imagination that’s more than active – it can be downright dangerous! Working late at the costume super-store Halloween Land, she gets lost in her own thoughts until something goes bump in the night. The rubber masks and plastic novelties are coming to life, and Eve must face ghosts, goblins, and gorilla suits made real.

High fantasy and heartbreak in an oversized 2012 holiday one-shot from Image Comics, written by Brandon Montclare with interior art by Eisner Award nominee Amy Reeder.

Amy’s fantastic work, which has also been on display in Batwoman and Madame Xanadu, was also roped in to provide this cover for Halloween Eve, a cover which for some reason makes me smile and think that it’s particularly clever. Not entirely sure why, but I do like it! :)

Review: Invincible #88 (Feb. 2012) Comic Books | My Reviews 27 JUN 2012

After the surprise turnout of General Thragg, to assist Mark (Invincible) against the arriving Oliver Grayson (Omni-Boy) and Allen the Alien last issue, writer Robert Kirkman slows things right down as Thragg attempts to talk Allen down from releasing the deadly Scourge virus (which would kill off all Vultrumite and Human beings currently living on our planet), by trying to convince him that the parties are currently involved in a bit of a Mexican stand-off. Things begin to get a little heated half way in though, thanks to the untimely arrival of the Guarding the Globe heroes, leading to an all out battle as Invincible attempts to stop Omni-Boy from killing all humanoid life on Earth through the deadly synthesized virus!

It must be said that after the events of issue 87, one almost expected #88 to be a proper battle royale, but as it turns out, Kirkman plays around with us and instead delivers about ten pages of solid, crammed in dialogue, as the two parties attempt to talk one another down. So if you’re not a fan of lengthy dialogue, then you’ll probably skip right through to the heavy action that fills the latter part of the book, but be warned, the dialogue (as expected from Kirkman) plays out pretty damn good!

With most of the book being static scenes in space, artist Ryan Ottley (who handles both the pencils and inks) doesn’t have to worry much with backgrounds for this issue, and so instead devotes his attention to the characters, putting in some great work that straddles just the right border between realism and cartoon, making for great looking comic book art. His character designs and facial features are all fantastic, and despite some silly looking feet at times, Invincible issue 88 is a well drawn adventure that is difficult not to visually enjoy.

Overall, despite the heavy dialogue that makes up the first half of this issue, Invincible #88 reads smoothly, features great lines and then follows up with some excellent action sequences, before finishing off with the final big twist, meaning that this is one title well worth picking up if it happens to cross your path!

PHP and ComicPress: Simple way to Retrieve the Latest Comic Image CodeUnit 17 OCT 2011

I have a WordPress/ComicPress-driven web comic site and wanted to show the latest posted comic image on another one of my websites. Because I couldn’t locate anything to return just the latest image for embedding purposes, I quickly whipped up the following PHP script to achieve this for me:

//determing the latest image in the comics folder and redirecting to it if calculated

//get the correct file path to use
$documentRoot =$_SERVER['DOCUMENT_ROOT'];

if (key_exists('SUBDOMAIN_DOCUMENT_ROOT',$_SERVER)){
	$documentRoot = $_SERVER['SUBDOMAIN_DOCUMENT_ROOT'];
}

//set the folder path to the comics folder
$folder = $documentRoot . DIRECTORY_SEPARATOR . 'comics';

//variable to hold the newest image path
$newestImage = '';

//loop through the comics directory. If file, compare the modified time to the currently set newest image. Update accordingly.
if (is_dir($folder)){
	foreach (scandir($folder) as $node) {
		$nodePath = $folder . DIRECTORY_SEPARATOR . $node;
		if (!is_dir($nodePath)){
		    if ($newestImage == ''){
		        $newestImage = $nodePath;
		    } else {
		        if (filemtime($nodePath) > filemtime($newestImage)){
			$newestImage = $nodePath;
		        }
		    }
		}
	}
}

//force redirect to the latest file, otherwise print an error message
if (is_file($newestImage)){
	header('location: ' . str_replace($documentRoot . DIRECTORY_SEPARATOR . 'comics','http://' . $_SERVER['SERVER_NAME'] . '/comics',$newestImage));
} else {
	echo '

Unable to determine latest image file.

'; }

Dump the above into a file and place it on your ComicPress server, before simply referencing it in an image tag on your target server. In other words, having saved the above to a file called latestcomicimage.php:

<img src=”http://comicserver.com/latestcomicimage.php” />

Nifty.

PHP: Create Image Object from BMP File with imagecreatefrombmp Function CodeUnit 06 MAY 2011

PHP by default uses the GD library for all its image processing and manipulation work, which handles most types of image files perfectly well. The one glaring omission however is when it comes to working with standard Windows Bitmap BMP files, where for example in amongst all the various imagecreatefromXXX function calls you’ll notice that there isn’t one for the plain old BMP photos.

Luckily though, there are more than a few user-generated implementations floating around the Internet, with one of the more simple but workable ones being presented here for my own future reference (because I’m a forgetful code monkey):

function imagecreatefrombmp($p_sFile) {
    $file = fopen($p_sFile, "rb");
    $read = fread($file, 10);
    while (!feof($file) && ($read <> ""))
        $read .= fread($file, 1024);
    $temp = unpack("H*", $read);
    $hex = $temp[1];
    $header = substr($hex, 0, 108);
    if (substr($header, 0, 4) == "424d") {
        $header_parts = str_split($header, 2);
        $width = hexdec($header_parts[19] . $header_parts[18]);
        $height = hexdec($header_parts[23] . $header_parts[22]);
        unset($header_parts);
    }
    $x = 0;
    $y = 1;
    $image = imagecreatetruecolor($width, $height);
    $body = substr($hex, 108);
    $body_size = (strlen($body) / 2);
    $header_size = ($width * $height);
    $usePadding = ($body_size > ($header_size * 3) + 4);
    for ($i = 0; $i < $body_size; $i+=3) {
        if ($x >= $width) {
            if ($usePadding)
                $i += $width % 4;
            $x = 0;
            $y++;
            if ($y > $height)
                break;
        }
        $i_pos = $i * 2;
        $r = hexdec($body[$i_pos + 4] . $body[$i_pos + 5]);
        $g = hexdec($body[$i_pos + 2] . $body[$i_pos + 3]);
        $b = hexdec($body[$i_pos] . $body[$i_pos + 1]);
        $color = imagecolorallocate($image, $r, $g, $b);
        imagesetpixel($image, $x, $height - $y, $color);
        $x++;
    }
    unset($body);
    return $image;
}

Nifty.

Online Image Crop and Resize Tool: PicResize.com CodeUnit 02 MAY 2011

Digital cameras of today produce photos that are far too large to just easily upload and use on the Internet for general things like Facebook or blogging and for this reason you should always keep a good image resizer and cropper tool close at hand, for manipulating those big images when you need to. One of the oldest, simplest and quite effective online image resize and crop tools out there is PicResize.com, having been running since March 2005 already!

It features a very uncluttered, simple to use interface that allows you to upload an image from your machine, use a crop bounding box to crop if necessary, select from a dropdown or input custom resize values, apply cool filters just for the fun of it and then save it back to your desktop.

Simple, powerful and effective.

Just what a good online tool should strive to achieve!

Related Link: http://www.picresize.com

PHP: Generate a Thumbnail from a JPG, PNG or GIF Image File Programming 28 JAN 2011

green php elephants - elephpantsWith PHP’s built in access to the decent GD graphics library, generating a thumbnail image from a larger photo turns out to be pretty simple to achieve. Below is a function you can use to create a thumbnail image from either a JPG, PNG or GIF source image.

To use, simply supply the file path to the source image as well as the desired width (though if not given it will be defaulted to 180 pixels wide). The height of the thumbnail is automatically generated so as to keep aspect ration the same.

The function is question:

function createThumbnail($pathToImage, $thumbWidth = 180) {
    $result = 'Failed';
    if (is_file($pathToImage)) {
        $info = pathinfo($pathToImage);

        $extension = strtolower($info['extension']);
        if (in_array($extension, array('jpg', 'jpeg', 'png', 'gif'))) {

            switch ($extension) {
                case 'jpg':
                    $img = imagecreatefromjpeg("{$pathToImage}");
                    break;
                case 'jpeg':
                    $img = imagecreatefromjpeg("{$pathToImage}");
                    break;
                case 'png':
                    $img = imagecreatefrompng("{$pathToImage}");
                    break;
                case 'gif':
                    $img = imagecreatefromgif("{$pathToImage}");
                    break;
                default:
                    $img = imagecreatefromjpeg("{$pathToImage}");
            }
            // load image and get image size

            $width = imagesx($img);
            $height = imagesy($img);

            // calculate thumbnail size
            $new_width = $thumbWidth;
            $new_height = floor($height * ( $thumbWidth / $width ));

            // create a new temporary image
            $tmp_img = imagecreatetruecolor($new_width, $new_height);

            // copy and resize old image into new image
            imagecopyresized($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
                $pathToImage = $pathToImage . '.thumb.' . $extension;
            // save thumbnail into a file
            imagejpeg($tmp_img, "{$pathToImage}");
            $result = $pathToImage;
        } else {
            $result = 'Failed|Not an accepted image type (JPG, PNG, GIF).';
        }
    } else {
        $result = 'Failed|Image file does not exist.';
    }
    return $result;
}

//calling the function
$result = explode('|',createThumbnail($sourceImagePath, 180));
            if ($result[0] != 'Failed'){
                header('Location: /thumbnails/' . basename($result[0]));
            } else {
                header('Location: error.gif');
            }

As you can see, the function above returns a string, with the string containing ‘Failed’ if the thumbnail generation has failed for some reason, otherwise returning the path to the generated thumbnail image.

Nifty.

Images of Highschool of the Dead Episode 12 Anime 27 OCT 2010

Fan service drenched panties and tits with zombies anime series, Highschool of the Dead drew to a close with its final episode ringing in at the number 12 mark. In return, we got a return to some great zombie action, loads of bullets, dynamite and sword slashes – complemented by the usual uber stylish CG action shots.

And all this thanks to a single high altitude nuke detonating and wiping out all electronics.

Not a good thing when you’re locked behind gates of the only fortress capable of stemming the unrelenting tide of the undead…

Car needs to be fixed, you need to hold down the fort

Anyway, here’s a boatload of images from episode 12 in order to wet your appetite just in case you haven’t picked it up yet!

highschool-of-the-dead-screenshot-1