fotografeer.nl

fotografeer.nl

  • Overzicht
  • Fotografeer tips
  • Blog
  • Albums
  • Categorieën
  • Sets
  • Aanvraag
Home / Essays / 2017

Share
2017/10/27

Problem with Tomcat, ImageIO and ServletOutputStream

During testing a Java Servlet on Tomcat that uses ImageIO and ServletOutputStream to display several guitar chord diagrams, I ran into a strange problem, that I can't explain or solve. The pattern used was found in several locations on the Internet. It creates a BufferedImage that is written to the ServletOutputStream:

// Set PNG content type
response.setContentType("image/png");
// Construct a diagram creator for the provided chord name
DiagramCreator diagramCreator = new DiagramCreator(chordName); // Create the image of a chord diagram. BufferedImage diagram = diagramCreator.createImage(width, height, notes); // Write the image to the output stream ServletOutputStream out = response.getOutputStream(); ImageIO.write(diagram, "PNG", out); out.close();

As long as the servlet "diagram.png" is called only once per HTML page, there are no issues and the correct image is rendered on the page. The problem starts when multiple calls to the same servlet are made on the same page. Simplified HTML example:

<img src="diagram.png?n=Cmaj&notes=E4/1/0,G3/3/0,C3/5/3">
E4/1/0,G3/3/0,C3/5/3
<img src="diagram.png?n=Cmaj&notes=E4/1/0,C4/2/1,G3/3/0,C3/5/3">
E4/1/0,C4/2/1,G3/3/0,C3/5/3
<img src="diagram.png?n=Cmaj&notes=G4/1/3,E3/4/2,C3/5/3">
G4/1/3,E3/4/2,C3/5/3 

The images are rendered in the HTML page, but repeatedly calling the same page will render different images each time. The text below the image should always match the text inside the image. The red circled ones don't. There the diagram image belongs to another chord pattern. So the wrong image is rendered, indicating to me that somewhere there is a buffering or thread-safety issue.

There is some debate if ImageIO is thread-safe. Also Tomcat is using a ServletOutputStream pool where a stream might be used simultaneously by multiple browser threads? Using .isReady() didn't provide a solution either. Whatever the root cause, it's blocking further development of the application :(

Reference material:

The dangers of Javas ImageIO
I'm using the Java ImageIO to dynamically serve images and get strange Exceptions from time to time. Is this a bug in Tomcat?
Java Code Examples for javax.servlet.ServletOutputStream
ServletOutputStream.isReady() returns true while it is not yet ready
Should I close the servlet outputstream?
temp imageio files in Tomcat gnerated by botBinFormat ?
Broken Pipe when writing bytes in ServletOutputStream
Problem with multiple images in a JSP (Connection reset by peer)

Read more in Blog

Share
2017/05/11

Licht - Kleurtemperatuur

Kleurtemperatuur

De kleurtemperatuur kun je zien als de kleurtint van het licht dat door een lichtbron wordt gegenereerd. De kleurtemperatuur wordt aangegeven in Kelvin (K).

Verloop

De afbeelding toont het verloop van de kleurtinten en de bijbehorende waarden van de kleurtemperatuur.

Wikimedia Commons, File:Color temperature sRGB.svg

Zo heeft de opkomende en ondergaande zon een rode tint. Standaard daglicht is wit. Sterke ledlampen, zoals b.v. de koplampen van een auto, hebben een blauwe tint.

Een overzicht van de waarde van kleurtemperaturen in verschillende licht situaties.

Zons-opkomst en -ondergang

Zonsondergang met een kleurtemperatuur van 2000 K.

Schaduw

Foto's in de volle schaduw hebben een kleurtemperatuur van 7000 - 10000 K en hebben een blauwe tint.

Zon

Foto in de volle ochtend zon hebben een kleurtemperatuur van rond de 4000 K met een gele tint.

Gloeilampen

Bij gebruik van gloeilampen (ongeveer 3000 K) krijg je een oranje tint.

Meerdere kleurtemperaturen

Hier een situatie met een combinatie van kleurtemperaturen door de schaduw op de voorgrond en zonlicht op de achtergrond.

Een combinatie van verschillende lichtbronnen met afwijkende kleurtemperaturen kan erg mooie effecten opleveren. Denk hierbij aan een combinatie van daglicht en kunstlicht, b.v. een verlicht historish gebouw bij zonsondergang. M.b.v. de automatische witbalans probeert de camera deze kleurtint(en) te corrigeren. Bij een combinatie van b.v. dag- en kunstlicht zal de camera een gemiddelde bepalen om tot een compromis te komen.

Read more in Fotografeer tips

Share
2017/05/10

Licht - Contrast

Contrast definitie

  • Een contrast is het verschil tussen tegenstellingen.

Licht en schaduw

Contrast in fotografie is de mate van verschil tussen licht en donker.

Een goede contrast-beheersing staat aan de basis van een goede foto. De linkse foto heeft een hoog contrast door het directe zonlicht. Hierdoor is het verschil tussen de lichte kant van het gezicht en de schaduw erg groot. Doordat de oogkassen iets dieper liggen treed daar snel schaduwvorming op. Met als resultaat dat de ogen nauwelijks zichtbaar meer zijn, terwijl dit bij portretten juist een belangrijk onderdeel van de foto is.

Model: Djowhenna Servaes

De rechter foto is genomen in een schaduwrijke omgeving. Door het gebruik van een reflectiescherm wordt de schaduw lichter en is het contrast beheerst. De ogen zijn nu goed zichtbaar.

Hoog contrast voorkomen

Er zijn verschillende situaties en technieken die helpen om contrast te beheersen.

  • locatie in de schaduw
  • bewolkte dag
  • reflectie scherm
  • difussie scherm
  • inflisten
  • studio fotografie

Direct en indirect licht

Direct licht ontspringt uit een puntlicht en veroorzaakt felle lichten en donkere schaduwen. Door het hoge contrast spreekt men hierbij ook wel van "hard licht". Onder puntlichten worden onder andere flitsers en gloeilampen gerekend. Zelfs de zon wordt gezien als een puntlicht.

Indirect licht wordt gereflecteerd en/of verstrooid. Denk hierbij aan licht via een reflectie scherm, een locatie in de schaduw of daglicht op een bewolkte dag. Zelfs een lichtgrijs grindpad kan licht reflecteren. Doordat in deze situaties het licht uit alle richtingen komt is het contrast laag en wordt dit aangeduidt als "zacht licht" of "difuus licht".

Doortekening in lichte en donkere partijen

Probeer in een foto zowel de lichte als de donkere partijen goed doortekend te krijgen.

Het wit in het band-patroon en het sieraad vertonen nog detail. Ook in het zwart zijn nog diverse schakeringen te ontdekken.

Andere vormen van contrast

Verschil tussen licht en schaduw is niet de enige vorm van contrast in een foto. Denk ook aan kleurcontrast, b.v. rood haar tegen een groene achtergrond. Of contrast tussen scherp en onscherp. Hier is op de ogen scherp gesteld en wordt de mate van onscherpte steeds groter wanneer de afstand tot het scherpstellpunt toeneemt.

Op deze foto staan de personen op de voorgrond in de schaduw en ligt de achtergrond in de volle zon, wat een contrast in kleurtemperatuur oplevert.

Read more in Fotografeer tips

Share
2017/05/05

Elfia 2017

Elfia

De meest opvallende portretten van Elfia 2017.

Gissy Gisbers
Ineke Akkerman
Tc Major Theodoricus

Read more in Elfia, Portret

elfia

Share
2017/01/15

Nikon Coolscan & Nikon Scan 4.0 on Windows 7/8/10

We now live in a digital age where every smart-phone has a camera and images can be posted on-line almost immediately. The older generation of photographers can still remember a time when photography involved loading film into a camera and having it developed. It usually toke several days before the photographs were ready.

Even if one has switched to digital photography since, large archives of images on film still exist. To allow these old images on film to become usable in the digital age, you need a way to scan them. Investing in a high-end film scanner (e.g Nikon Coolscan LS-8000 ED) made sense in the early days of digital cameras with low resolution. It allowed for extended use of investments in analog camera equipment and produced better results than the digital cameras at that time. A lot has changed since then and high-end cameras now offer resolution that rivals and exceeds film.

On the downside, computer hardware and operating systems have become obsolete making it harder to use this scanning equipment. E.g. the Nikon Scan driver and software were not updated to work after Windows XP. Even parts are getting scares and it might not be very long before Nikon stops servicing Nikon Coolscans.

A while ago I found an article "Nikon Coolscan and Nikon Scan 4.0: Driver for Windows Vista 64 bit, Windows 7 64 bit and Windows 8 64 bit" online, that describes how get the Nikon Scan 4.0 driver working on Windows 7/8. After applying the steps I can now use the Nikon Coolscan and Nikon Scan 4.0 on Windows 7, giving it a new lease on live. And after upgrading to Windows 10, this still works.

Update 2021-05-09

When trying to scan after a few years (and several Windows 10 updates), I ran into an issue with the Nikon Scan 4.0.3 driver. The Nikon Scan 4.0 software showed a message "Nikon Scan was unable to find any active devices".

When I checked the device manager, the Nikon SUPER COOLSCAN 8000 ED was listed under Other Devices, while it should be under Imaging Devices (cameras and scanners). The driver is not digitally signed and was therefore not accepted by Windows any more. So my problem was related to the "the third-party INF does not contain digital signature information" issue that old drivers sometimes pose in Windows 10. To install the driver anyway I needed to temporarlily circumvent the digital signature enforcement. Found instructions online and executed the following:

1) Select the Start button in the lower left corner of your screen.
2) Select Settings -> Update & security
3) Select System Recovery
4) Below Advanced Startup Options, select Restart
5) After restart, the Choose an option screen is displayed
6) Select Troubleshoot -> Advanced options -> Startup Settings -> Restart
7) After restart, in the Startup Settings menu, select 7 (or F7). This triggers the 7) Disable driver signature enforcement option
8) Your computer will restart once more and (temporarily) disable the digital signature enforcement.
9) Start the Device Manager
10) Find the Nikon SUPER COOLSCAN 8000 ED entry below Other Devices
11) Right-click Nikon SUPER COOLSCAN 8000 ED and select Update Driver Software
12) Select Browse my computer for driver software
Note: I have an already updated Nks1394.INF file (see instructions above) in C:\Program Files (x86)\Common Files\Nikon\Driver\Scan1394 and will use that
13) Select the correct location of your driver via the Browse button
14) Select OK
15) Back in the Update Driver Software window, select Next to install the driver
16) When all goes well, your scanner should now be listed below Imaging Devices (cameras and scanners).

17) Don't forget to restart again to re-enable the digital signature enforcement.
18) Then start the Nikon Scan software and your scanner will be recoginzed again. The normal scan options should appear and scanning can resume.

Reference material:

Nikon Coolscan and Nikon Scan 4.0: Driver for Windows Vista 64 bit, Windows 7 64 bit and Windows 8 64 bit
Unoffical Vista X64 driver of LS-8000ED/9000ED for Nikon Scan 4.03
http://imaging.nikon.com/lineup/scanner/scoolscan_8000_ed/
https://en.wikipedia.org/wiki/Nikon#Film_scanners
http://blog.controlspace.org/2010/05/nikon-scan-on-windows-7-and-vista-64.html
Hoe kan ik stuurprogramma's installeren die niet digitaal ondertekend zijn?
Find safe mode and other startup settings in Windows 10
https://petapixel.com/2015/04/24/12-reasons-photographers-still-choose-to-shoot-film-over-digital/
https://petapixel.com/2016/08/19/film-photography-making-stunning-comeback/

Read more in Blog

coolscan

View all essays by month
View all essays by category
  1. 14

    Blog

  2. 13

    Fotografeer tips

  3. 6

    Portret

  4. 6

    Elfia

View all essays by tag
  1. 9

    arduino

  2. 8

    attiny85

  3. 8

    nano

  4. 6

    elfia

  5. 2

    coolscan

Tweet
  • Overzicht
  • Fotografeer tips
  • Blog
  • Essays
  • Albums
  • Inhoud
  • Twitter
  • Facebook
© 1979-2025 Peter van Loon - fotografeer.nl - since 2003 | Built with Koken