select object_id_two as item_id
from acs_rels
where object_id_one = :user_id
and rel_type = 'user_portrait_rel'
insert into images
(image_id, width, height)
values
(:revision_id, :original_width, :original_height)
select live_revision as revision_id
from cr_items
where item_id = :item_id
update images
set width = :original_width, height = :original_height
where image_id = :revision_id