Marcel Eichner // Ephigenia

  • Home
  • Illustration
  • Code
  • Kontakt

Aktuelle Projekte

Horrorblog.org
jQuery.slideShow
Franklin
code.marceleichner.de

This Blog-Website is built with Harrison!

Blogs & Freunde

Gimmixx
Martin Fleck
Torsten Bergler
Jens Franke
Robokid
Peter Kröner
Polycoder
Coding Horror
Lotterliebe
CodeBalancer
Pseudocoder
Migrador
Dachdeckermeister Peter Arold in Werda, Plauen, Hof und Umgebung La Petite Provence - Pension und Festsaal in Leisnig Piv-Berlin, Immobilienverwaltung Verwaltung Berlin blogoscoop

#507

04.07.2011 19:51
0 Kommentare
Share
  • php
  • apache
  • gd-lib
  • image
  • server
  • nginx
  • static
  • content
  • delivery
  • .htaccess
One problem when relaunching large projects with a ton of images is to re-create all the thumbnails that users have uploaded in the years. If you don’t use paperclip (ruby) or anything like it in PHP (is there any like it!?) where you can run run one command to re-create all the thumbnails in all specified sizes your can try to keep it flexible and create every image on demand.

Theory

The Webserver should serve the image if it exists. If the file does not exist, the request should be redirected to a PHP script that searches and creates the requested image file (in requested size) at exactly the location it was originally requested. The second request on the file will not be redirected to the PHP script and will server the image that now exists.

Practice

So the first thing to archive is to send the request of a not existing image to a PHP file. That’s easy if you’re familiar with all the nginx directives:

This rule can be combined with the anti-hotlinking rules for images with nginx I showed you last week.

After that we need to create a format that includes width and height of any requested image so that the
thumbnailer.php
knows which size the created image should have. A valid request for a resized file should always have all parameters (width, height) in it:
../img/public/9c4be029/438xauto/filename.jpg

This makes it easy to split up width, height with a regexp in
thumbnailer.php
. The following code is just an example. You’re surelly integrate the logic into your frameworks:

That’s it! After that you can request any image in any size on your webserver by only creating it once it’s requested.

There are some things you can add, like other parameters in the
$formatRegexp
string to add different resizing methods or even filters, or limitations on the
width
and
height
parameter.

Appendix: Apache

It’s almost the same thing with apache. Just add a few lines to your
.htaccess.
and all your image requests are redirected to the thumbnailer (or anything):

#506

28.06.2011 11:16
0 Kommentare
Share
  • config
  • facebook
  • server
  • nginx
  • hotlinking
  • referer
  • block
  • how-to
Almost two weeks ago I moved my personal blog-project horrorblog.org from a domainfactory managed hosting server to a JiffyBox which is a scalable cloud server solution also by domainfactory. I won’t talk about the setup for now (but later this or next week) but I want to show you an example for a nginx config file that prevents your images from beeing hotlinked but still enabling google and facebook.

Prevent hotlinking in nginx is really simple and some rules and examples can be found via google:
# apply this rule on any location that’s an image using Regexp
location ~* \.(png|gif|jpg|jpeg|swf|ico)(\?[0-9]+)?$ {
  # block empty blocked or whiteliste referers
  valid_referers none blocked horrorblog.org www.horrorblog.org;
  if ($invalid_referer) {
    return 403;
  }
}

This works fine, unless you won’t have your images displayed on facebook when anybody likes your stuff with the facebook share button (og:image) or in google image search. The solution that enables facebook to grab the images from your host is by adding
~\.facebook\.
and
~\.fbcdn\.
to the whitelist of hosts:
# apply this rule on any location that’s an image using Regexp
location ~* \.(png|gif|jpg|jpeg|swf|ico)(\?[0-9]+)?$ {
  # block empty blocked or whiteliste referers
  valid_referers none blocked horrorblog.org www.horrorblog.org ~\.google\. ~\.yahoo\. ~\.bing\. ~\.facebook\. ~\.fbcdn\.;
  if ($invalid_referer) {
    return 403;
  }
}

#490

22.11.2009 21:33
0 Kommentare
Share
  • Web
  • osx
  • virtual
  • box
  • google
  • os
  • preview
  • test
  • screenshots
Das Horrorblog in Chrome OS
Letzte Woche Freitag Nacht wurde von Google der Source Code aka Quellcode zu deren Online-Betriebssystem Chrome OS released. Ein paar Videos und noch mehr Infos gibt’s in dem dazugehörigen Blog-Post im Chrome-Blog.

Wer es drauf hatte auf Ubuntu seinen eigene Version zu compilieren kann sich glücklich schätzen und kennt sich wahrscheinlich gut damit aus. Ich musste mich mit dem Versuch begnügen das ganze mit einem Festplatten-Image von GDGT in Virtual Box (3.0.12 r54655) auf Snow Leopard (10.6.2) zum Laufen zu bekommen. Nachdem ich den Netzwerkadapter auf Desktop umgestellt habe, Linux - Ubuntu - Other Linux wie in der Anleitung angegeben hatte zeigte sich auch endlich der Login-Screen! So, jetzt noch die Tücken der englischen Tastatur besiegen und nachdem das "z" im Passwort auch hübsch als "y" auf der Tastatur eingegeben wurde komm ich auch mit meinem Google Account rein! (Manchmal geht das wohl nicht weil die Server überlastet waren?)

Ja, wie ist es? Ganz nett - es kann noch nich’ viel, alles läuft quasi im "Browser". Das Schachspiel das man schon gesehen hat vielleicht läuft in Flash und ich glaube nativ installiert, auf einem Netbook, ist Chrome OS superschnell! Frisch hochgefahren mit 3 Fensterchen offen, verbrauchte Chrome OS nur ca. 50MB!

Ich bin gespannt wie das fertige System aussehen wird. In einem Jahr wird sich ja hoffentlich noch viel Ändern und noch mehr "Programme" geboten werden. Zum Websites-Testen braucht man Chromium auf jeden Fall nicht - da reicht auch der Chrome-Browser.

#452

06.05.2009 14:50
0 Kommentare
Share
  • code
  • php
  • thumbnail
  • gd-lib
  • image
Seit letzter Woche sind die Thumbnails auf dieser Seite ein wenig schärfer geworden!
Die GD-Lib in PHP erzeugt unscharfe Thumbnails. Wenn man Convolution-Filter auf das fertige Thumbnail anwendet bekommt man allerdings wunderbar scharfe Thumbnails:
// angenommen $h ist das image-handle
$m = array(
  array(-1, -1, -1),
  array(-1, 16, -1),
  array(-1, -1, -1)
);
imageconvolution($h, $m, 8, 0);
Viel Spass damit!

#230

14.08.2005 00:41
0 Kommentare
Share
  • Web
  • fundstücke
  • seele
Kleiner insider ... T-Shirt mit Baum auf der Brust ... Anspielung? auf ... das vielleicht ?

#37

11.07.2004 18:46
0 Kommentare
Share
Hab grade erfahren das Spatium-Newsletter im Websites Buch vom Feierabend Verlag genannt wird und das mein Name zweimal auftaucht. Das reicht doch für einen Presse Eintrag oder? Dank an Martin

#38

11.07.2004 12:51
0 Kommentare
Share
Ich hab jetzt seit fast 2 Wochen diese Drumdingens ... wollt ich schon immer mal haben. Nachdem kein Netzteil dabei war, läuft es jetzt mit dem 9V Adapter (obwohl 12V bevorzugt) vom alten Nintendo NES - Was alles geht *staun*

Ja und heute auch schon wieder bisgen gespielt, war schon wieder vor 8 Wach und auf den Beinen, echt schlimm, ich hoffe das wird nicht mode!

#41

07.07.2004 23:07
1 Kommentar
Share
Neues Badly Drawn Boy Video, gefällt mir:
Badly Drawn Boy - Year of the Rat

#42

07.07.2004 21:17
0 Kommentare
Share
Wooster Collective:
Wooster Collective
marceleichner HTML5 Harrison Theme (Validate Source), © 2010 by Ephigenia M. Eichner, Impressum